Wave Spawn System — Part 2

Joshua Kroeker
4 min readMay 15, 2023

--

Hello! This is the continuation of my last article, a part two to the Wave Spawn System that is being implemented into my game, Galaxy Shooter. In this second part, we will be going over how to increase the amount of enemies spawned in each wave after a certain number of waves are spawned. A flickering visual indicator will also be displayed so that the player knows to prepare for trouble!

To start, a UI Text object with the settings for it as shown below is required to be able to tell the player larger waves of enemies are going to be spawned.

We’ll then go straight into our SpawnManager class and add a new variable that will keep track of how many waves of enemies must be spawned before we can allow for the wave size to increase.

We’ll also want a reference to the UIManager as well to be able to connect the UI to the functionality of this system.

Next, we’ll go into the SpawnEnemyRoutine and make sure that we increase our newly added counter every time we finish spawning a wave. We’ll also make sure to add a check to see if we have spawned five waves yet.

In this newly added check, we will reset the counter because at this point, we should increase the enemy wave size and add a slight delay to allow for the UI to do its flicker effect.

Speaking of the flicker effect, we’ll create a new overload for the previous StartFlickerEffectRoutine (in the UIManager class). The main difference is that it will take any GameObject and flicker it for a custom duration.

This new coroutine will almost be like the previous overload but it will flicker until we’ve reached zero on our duration which acts like a timer in a way.

And just to make sure that we turn off the actual GameObject we will be flickering.

Now we need something we can actually flicker, in our case the Text object we created in the beginning, so let’s add that to our list of variables at the top of this class.

But now we actually need to do something with our newly cached reference to our Text object and our new overload for our flicker effect. So, we will create a new method that will start that new overload.

With this newly created method, we will now call it in our check for if we can increase the enemy wave size back in our SpawnManager.

All there is left is to first make sure our Text object is connected in the Inspector to the UIManager.

And that our UIManager is now linked up to the SpawnManager.

And our result is as shown below!

Notice how the size of the wave increases from 3 to 4!

We now have a fully functional wave spawning system where enemies in the last part are spawned in waves rather than individually, and the waves grow in number in order to increase the difficulty for the player. If you have stuck through both parts, I appreciate it and look forward to the new addition to my Galaxy Shooter project.

--

--