I’m new to Unity. I’m trying to instantiate a 3x3 grid of cards with the following code. When I run this, I get cards all the way across and down the screen when I only expect a 3x3 grid. If I remove the loops and call Instantiate, I just get the single card like I expect. What am I doing wrong?
using UnityEngine;
public class BoardBuilder : MonoBehaviour
{
public GameObject Card;
public int width = 3;
public int height = 3;
void Start()
{
for (int y = 0; y < height; y++)
{
for (int x = 0; x < width; x++)
{
Instantiate(Card, new Vector3(x*25 - 100, y*-32 + 37, 0), Quaternion.identity);
}
}
}
}