C
C#17mo ago
whiteviperx

❔ 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);
}
}
}
}
}

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);
}
}
}
}
}

3 Replies
whiteviperx
whiteviperx17mo ago
and I want to rotate each of the objects so the correct side is up
whiteviperx
whiteviperx17mo ago
Right know the script depending on how i make a few changes, still always shows the #1 side of the object, I want the #3 side
Accord
Accord17mo ago
Looks like nothing has happened here. I will mark this as stale and this post will be archived until there is new activity.