❔ Creating a grid

Trying to create a 5 x 5 grid, but because object is 3d it shows up sideways

using UnityEngine;

public class LevelManager : MonoBehaviour
    {
    // V = vertical grid qty
    private const int V = 5;

    // H = horizontal grid qty
    private const int H = 5;

    [SerializeField]
    private GameObject tile;

    // Start is called before the first frame update
    private void Start()
        {
        CreateLevel();
        }

    // Update is called once per frame
    private void Update()
        {
        }

    private void CreateLevel()
        {
        float tileSize = tile.GetComponent<MeshRenderer>().bounds.size.x;

            {
            for(int x = 0; x < H; x++)
                {
                for(int z = 0; z < V; z++)
                    {
                    GameObject newTile = Instantiate(tile);
                    newTile.transform.position = new Vector3(tileSize * x, 0, tileSize * z);
                    }
                }
            }
        }
    }
Was this page helpful?