Random Planet Generator

The WaitForSeconds() is having absolutly no effect and it is creating alot more than the amount from the random number…

var MinPlanets = 10;
var MaxPlanets = 100;
var PlanetTemp : GameObject;
function Start () {
var GenAmnt = Random.Range(MinPlanets,MaxPlanets);//Returns the number chosen to make a random game!
while (GenAmnt > 0) {//Gen Planets here
Debug.Log(GenAmnt);
var NewPlanet = Instantiate(PlanetTemp,Vector3(10,GenAmnt,10),Quaternion(0,0,0,0));
yield WaitForSeconds(500)
GenAmnt = (GenAmnt - 1);
}
}

semicolon after waitforseconds ?

Its weird, when I did that there was no wait but the script didn’t crash Unity anymore. :lol:

So it’s still not working?

I don’t think you can use yield inside Start() - from the manual:

Since Start() is only called once, the yield statement won’t work. So you’d have to put the generation stuff in a seperate function.