ok so im following this tutorial about prims maze and everything is correctly coded I followed everything in pretty much the exact same way. the problem is that when i hit the play button unity freezes up and the grid doesn't form. its fine when its just instantiating the x for(int x=0,x
this is the code i used
this is the tutorial i am following
public class GridScript : MonoBehaviour { public Transform CellPrefab; public Vector3 Size;
void start()
{
CreateGrid ();
}
void CreateGrid(){
for(int x = 0; x < Size.x;x++){
for(int z = 0; x < Size.z; z++){
Instantiate(CellPrefab, new Vector3(x, 0, 0), Quaternion.identity);
}
}
}
}
but when I have used this code for a different grid it works perfectly fine public Transform PlatPrefab; public Vector3 Size; public int platX, platY, playZ;
// Use this for initialization void Start () { MakeGrid(); }
// Update is called once per frame void MakeGrid(){
for (int x = 0; x < Size.x; x++) {
for (int z = 0; z< Size.z; z++) {
Instantiate(PlatPrefab, new Vector3(x+platX,platY,z+playZ), Quaternion.identity);
}
}
}
does any one know why this is happening
z < Size.z
and notx < Size.z
as you're currently doing. This results in an endless loop -> Unity freezes. – bummzack yesterday