i am a unity game developer,and i m pretty bad with the grids.
i have to create a prototype for cube movement in a grid.
but i don’t know how to create a grid.
any thing like pseudo code or algorithm for creating a grid in unity will be very much helpful for me.
public var plane : Transform;
public var gridSize : Vector3 = Vector3(4,0,4);
private var canCreateGrid : boolean = true;
function Update ()
{
if (Input.GetKeyDown(KeyCode.Return) canCreateGrid)
{
canCreateGrid = false;
CreateGrid();
}
if (Input.GetKeyDown(KeyCode.Delete))
{
var clones = GameObject.FindGameObjectsWithTag ("PlanePrefab");
for (var clone in clones)
{
Destroy(clone);
}
canCreateGrid = true;
}
}
function CreateGrid ()
{
for (var x = 0; x < gridSize.x; x++)
{
for (var z = 0; z < gridSize.z; z++)
{
Instantiate (plane, Vector3(x * 10, 0, z * 10), Quaternion.identity);
}
}
}