Closing space between instantiated game objects

Hi all,
quick question, just wondering how do I close the space between instantiated objects in a grid pattern,

with my current code the grid is as follows with about 10 spaces on the X and Y

o…x

x…o

        brick[0] = new GameObject[2] { x, o };
        brick[1] = new GameObject[2] { o, x };
     
        for(int i = 0; i < brick.Length; i++)
        {
            for (int j = 0; j < brick[i].Length; j++)
            {
               brick[i][j] = Instantiate(brick[i][j],new Vector2( i, j - 2),Quaternion.identity) as GameObject;
               brick[i][j].transform.localScale = new Vector3(.1f,.1f,0);
            }
     
    }

and I am trying to get x and o a lot closer together

Thanks for all the help.

Get the vector point from one object to the next, and each update move a object in that direction.

You can get a direction vector just put subtracting the 2 object positions and normalizing the resulting vector

1 Like

Thanks for the quick reply, I am kind of confused because my gird doesn’t move it is a static grid and I need to place more blocks within the confined space, so how would I get each block to be closer?