Tile-Based Ground – Unity3D (C#)
To create a tile-based ground, we need a simple matrix system. A (row X column) matrix will take a plane texture and draw it in each cell.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
public GameObject plane; public int width = 10; public int height = 10; private GameObject[,] gridd = new GameObject[30, 30]; void Start () { for (int x =0; x < width; x++) { for (int y =0; y < height; y++){ GameObject gridPlane = (GameObject)Instantiate(plane); gridPlane.transform.position = new Vector2(gridPlane.transform.position.x + x, gridPlane.transform.position.y + y); gridd[x, y] = gridPlane; } } } |
©Coffee Break Codes – Tile-Based Ground – Unity3D (C#)
You should create some remark area or like button so that others can appreciate your coding. Your tuts are pretty helpful!