- Home /
Question by
Jackop222 · Dec 15, 2013 at 02:49 PM ·
function updatevar type
Why does this for loop crash my unity?
I'm trying to fill a 100 by 100 square with blocks but when i do this it crashes my unity.
var Land : GameObject;
function Start () {
}
function Update () {
for(var x : int = 0; x < 100; x++)
{
for(var y : int = 0; y < 100; y++)
newObject=Instantiate(Land);
Land.transform.position = Vector3(y, 0, x);
}
}
Comment
Answer by aldonaletto · Dec 15, 2013 at 02:51 PM
You're modifying the prefab! Modify the newObject block instead:
for(var y : int = 0; y < 100; y++)
var newObject: GameObject = Instantiate(Land);
newObject.transform.position = Vector3(y, 0, x);
}
Your answer
Follow this Question
Related Questions
How to stop spawn after a limit (int) 1 Answer
Cooldown button system 1 Answer
How to remove decimals from Vector3.Distance 3 Answers
Breaking a loop, Javascript? 3 Answers