2D Shooter: Controlling the Enemy Spawns with the Asteroid
Objective: Initiate enemy and powerup spawns only once the Asteroid is destroyed.
First thing we’re going to do is move the code calling the spawn coroutines in the SpawnManager into their own method so the start method doesn’t start them right away.
Now go to the Asteroid script. Make a variable for the SpawnManager and find it in the start method while also using getcomponent to access the script.
Now call the StartSpawning method right before we destroy the asteroid.
To create a delay we can add “yield return new waitforsecond” in the places where the enemies and powerups are instantiated.
Now we should get a good breather before having to fight any enemies!