Road to Game Dev: Enemy Wave Management (Part 2)

Rowan Mcmanus
2 min readSep 16, 2021

Now that enemies can have advanced movement patterns, the next logical step is to tie multiple enemies together into a full wave.

Basic Wave Setup

The easiest and most straightforward way to set up a wave is to do something similar to how we created the Triple Shot; create an empty game object that functions as the container for all the enemies. The catch is that we want this container to be a little bit more intelligent so that it can spawn enemies in the right places at the right times. The code is pretty simple, though:

Now, each wave container finds the spawn manager, finds the enemy container, and then starts running coroutines to spawn each enemy on the appropriate delay. This is actually just a stripped-down version of the movement code we used before. The variables used are simply an array of enemy prefabs, an array of the delays between each enemy, and an array of where to spawn them. Here’s what that looks like in the wave shown above:

Modifying the Spawn Manager

The last step is to now modify the spawn manager to manage all the waves, using the same technique as the wave manager. This time, we’re filling the array with wave containers instead of enemies.

With this, we have a functional wave system! The benefit of this is that each wave container can do more than just spawn enemies — you can also spawn powerups, obstacles, and many more things using the same wave container. In fact, pretty soon we’ll be using it to make the level’s final boss…