title: Centering Multiple Objects at Zero When Instantiating
body: <p>I am trying draw 'x' objects onto the screen where center of the container is the middle of all 'x' objects.</p>
  <p>So, if I have a box where width=100 and height=100 and I want them to have a spacing of 100 and in this instance, x=5 (5 boxes), how do I get the boxes to start drawing at -450 to 450 with 0 being the center.</p>
  <p>here is a picture of my example (<a href="https://imgur.com/a/QwrCvb7" rel="nofollow noreferrer">https://imgur.com/a/QwrCvb7</a>)</p>
  <p>(I'm using C# in Unity. I shortened a lot of stuff because I am more focused on the formula and less on the syntax of instantiating or the declaring of objects and values)</p>
  <pre><code>Object container = new Object();
  Object box;
  
  x = 5;
  
  container.width = 1500;
  container.height = 300;
  
  box.width = 100;
  box.height = 100;
  
  int boxSpacing = 100;
  
  int i = 0;
  //normally, an if statement would work, but I need to use foreach other things
  foreach (int number in x)
  {
     Object newBox = Instantiate(box, new Vector2(0,0), Quaternion.identity, transform);
     newBox.transform.localPosition = new Vector2(getX(x), container.height / 2);
      
  }
  
      float getX(int count)
      {
          return -1 * (count * box.width + (count - 1) * spacing) / 2 + (box.width / 2);
      }
  </code></pre>
  <p>I'm struggling with the formula for getX where (in this instance) I would start at -450 and end at 450. In fact, I think I am missing the mark all together. My plots either got all negative or all positive.</p>