- Home /
For Loop Won't Stop Running...
Hello, for some reason my for loop won't stop running. I don't understand why, but my code is:
var Prefab : Transform;
var forValue : float;
var XPos : float;
var YPos : float;
var ZPos : float;
function Start(){
XPos = 1.829174;
YPos = -105.606;
ZPos = 1.927386;
}
function Update()
{
for (forValue = 0; forValue <= 68; forValue++) {
Debug.Log("Value of X is: " + forValue);
Instantiate(Prefab, new Vector3(XPos,YPos,ZPos), Quaternion.identity);
XPos += 1.829174;
}
}
Thank you if you know how to fix this :D
Comment
Best Answer
Answer by Bunny83 · Jul 08, 2013 at 07:54 PM
your for loop is inside Update, so you create 69 instances of your prefab every frame.
If you want to run the loop only once, put it inside "Start" and not Update
OHHH, xD i'm such an idiot :P Thank You So $$anonymous$$uch :D
Your answer
Follow this Question
Related Questions
Enemy Script Help 0 Answers
Poblem in My Code 1 Answer
Keycode issues, newb(Sensationalist title removed) 2 Answers
Problem With Enemy AI 0 Answers
My monster only choose one Target 2 Answers