How to Create a Wave System in Unity (Part 3 — Start New Wave)

Objective: Create an empty game object called web container, make all enemies of the current wave child of this game object and start a new wave when all enemies are destroyed.

In the SpawnManger script I declared an int variable called “_waveCounter” that will be used to know the current wave number. Also defined a get method to access this value from another script.

In the UIManager script I create a SpawnManager variable to get the reference to the spawn manager object (the value is assigned from the inspector) and in the function to show the text we get the value of the _waveCounter to show it in the UI.

Next step is to create an empty object called Wave_Continer that is gonna be used to know all the enemies of the current round.

In the Spawn Manager I declared a variable to get the reference to the wave container. Then create a function to check if _stopSpawn flag is true and if there is no enemies to call the start spawning routine.

In the same script in the spawn enemies routine, I make the new enemy child of the wave container.

And that’s it!!! Now when the player destroys the enemies of the current wave, the spawn manager starts the next one.



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store