My 90 day journey becoming a Unity game developer: Day-30

Rhett Haynes
2 min readJul 12, 2021

--

Objective: Controlling the spawn wave through destroying the asteroid.

Final result of spawn wave starting 3 seconds after asteroid is destroyed.

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.

Spawning starts right away after the asteroid is destroyed.

Inside the coroutines of enemies and powerups, pause the them from being spawned for 3 seconds before the while loop actually begins.

Coroutines for the enemies and powerups are paused for 3 seconds.
Spawn waves start in 3 seconds.

Next time we will add thrusters to the player’s ship.

--

--

Rhett Haynes
Rhett Haynes

Written by Rhett Haynes

Learning to become a Unity game developer.

No responses yet