Hey, continuing off the flying sphere game I talked about in this other topic, I’m now trying to figure out how to make flying spheres (i.e. asteroids) to keep instantiating themselves for a set period of time.
Right now I’ve got it set up so that it instantiates once every second, and then stops after the asteroid has been instantiated 15 times. But I want it to be able to instantiate an infinite number of times, but still only once a second, and stop after a set time limit has been reached. (Though later I may want to adjust it so that it can speed up or slow down the frequency of instantiation as the game progresses).
Here’s the code:
var asteroid : Transform;
var asteroidCount = 15;
function Start ()
{
for (i = 0; i < asteroidCount; i++)
{
Instantiate(asteroid, Random.insideUnitCircle*15, Quaternion.identity);
yield WaitForSeconds (1);
}
}