[SOLVED] Spawn plus one to the amount of killed enemies and repeat

How do I…

Increase the amount of spawned enemies by one each time all currently spawned enemies are killed?

What is the expected result

An enemy is spawned. Enemy gets killed. Two enemies are spawned. Two enemies are killed. Three enemies are spawned, etc.

How would you achieve that logic?

A dinky way to do it would be to use a variable and add one to each wave end.

Spawner variable starts at say 5. And at the end of the wave when they’re all dead, +1 to Spawner.

All good! I figured it out! Thanks!

Can you post your solution to help future users?

Hey, sure thing!

I declared a simple number variable in the scene and left it empty (0) - Zombie_Spawn.
In the events, I start with a condition that no Zombie objects are in the scene and change the variable to add +1.

Then I start spawning one Zombie at a time in the scene, but repeat the event +1 to the variable.

And then it starts looping. If I kill all Zombie objects, there are 0 objects in the scene, so it adds +1 to the variable and repeats the creation +1.

Depending on where I place the “Change the variable” action, it will start the scene with 2 Zombies or with 1 - see the commented events in the screenshot.

1 Like