C
C#

help

❔ Creating a grid

Wwhiteviperx3/4/2023
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);
}
}
}
}
}

and I want to rotate each of the objects so the correct side is up
Wwhiteviperx3/4/2023
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
AAccord3/5/2023
Looks like nothing has happened here. I will mark this as stale and this post will be archived until there is new activity.

Looking for more? Join the community!