My 90 day journey becoming a Unity game developer: Day-30
Objective: Controlling the spawn wave through destroying the asteroid.
In the SpawnManager script, we want to take the powerups and enemies spawn routines and make them spawn when the asteroid is destroyed. Create a new method name StartSpawning(), add the start coroutines of the enemies and powerups from the Start() function.
We will take the method StartSpawning() and use it in the Asteroid script. Create a variable that will be the handle to the SpawnManager class. Inside the Start() function, use the variable to access the SpawnManager component.
Down in OnTriggerEnter(), when the laser is destroyed, but right before the asteroid itself is destroyed add the reference to the SpawnManager() class and use the StartSpawning() method for the spawn waves.
When we play the game and destroy the asteroid, the spawn waves begin immediately not giving the player much time to react. Let’s add a time delay to allow the asteroid to be destroyed and give the player a little time before reacting to the spawn waves.
Inside the coroutines of enemies and powerups, pause the them from being spawned for 3 seconds before the while loop actually begins.
Next time we will add thrusters to the player’s ship.