Grid / Pattern with Script

Can someone help me with what might be a simple thing I am overlooking. The code below works as it should. I am trying to get it to work in a 2D plane. Meaning I am trying to get a 5 by 5 grid display along X,Y. Right now it’s X,Z. I tried playing around with Vector3 pos = new Vector3 (x, 0, y) * spacing; by changing the x,yz value and no luck.

Thanks for nay help.1

void GridFormation ()
        {
                float gridX = gridXCount;
                float gridY = gridYCount;

                for (int y = 0; y < gridY; y++) {
                        for (int x = 0; x < gridX; x++) {

                                Vector3 pos = new Vector3 (x, 0, y) * spacing;
                                Instantiate (prefab, pos, Quaternion.identity);
                        }
                }



        }

If you use Vector3 (x, y, 0) it do not work? Sure?
Try to convert the int values to float:

Vector3 pos = new Vector3( (float)x, (float)y, 0f) * spacing;

It’s working in X,Z because you’re assigning the value y to the Z component of the position vector. Assign it to the Y component instead.

iMob is incorrect because ints will implicitly cast to floats so his code does nothing differently.

Thank @KelsoMRK but I tries your suggestion as well. I can remember how to do the offset. The prefabs stack on top of each other. I open to any other suggestions. And thanks

Stacking on top of each other is what I would expect from an evenly-spaced grid of prefabs along the X Y plane so I’m not really clear on what you’re trying to do at this point.