How to Create a Wave System in Unity (Part 1 — Set Spawn Timing)

Spawning enemies for a specific amount of time.

Objective: Enable the spawn manager for 10 seconds and disable it to start the wave.

The idea is easy. I have to enable the spawn manager object, wait 10 seconds and disable it. Each wave in this game consists of a certain quantity of enemies spawned in each wave.

In the SpawnManager script I created a function to set the value of the “_stopSpawn” variable, this is the flag that indicates to the spawn manager to start or stop spawning.

Then I create a coroutine called “ActiveSpawnTimerRoutine” to wait 10 seconds and set the _stopSpawning variable to true and in the StartSpaning function we call all spawning coroutines.

And good to go!!! We can spawn enemies 10 seconds per wave. In the next article I am gonna show how to show the current wave number with a UI text element.

A Software Engineer passionate about game dev and interactive products with Unity. I consider video games to be the artistic expression of programming.