How do I make a spawning system?

Hello,

I’m a beginner in GDevelop and programming in general.

I’m trying to create a spawning system for my tower defense game. and I don’t really know how…

What I want is for a wave of different enemies to spawn when the player presses a button. Then, the wave should end after all the enemies are defeated, allowing the player to move to the next scene or trigger another action.

Currently, this works, but only for one type of enemy. also I’m unsure how to make it so that when all the enemies are defeated, a specific action occurs.

I’d suggest modifying the WoodsWaver from an array of numbers to an array of structures, changing the Queue variable to a structure and creating an enemy object group.

I’d also suggest adding the “ArrayTools” extension. It makes for more compact actions to manipulate arrays.

The structures would hold the enemy’s object name and the number to spawn for the level.

The enemy group object would have every enemy that can be spawned in it.

You can then spawn the enemy from the object group using the name from the structure.

As a rough guide, the variables Queue and WoodsWave2 would look something like:

The enemy object group (I’ve called it WaveEnemy) would look like:

You’d then have to modify the StartWave click events to:
image

the spawning event to:
image

and the last event to:
image


You can check if all the enemies have been defeated with:
image

1 Like