How to end game when all enemies are destroyed?
Currently I'm trying to end the level once all enemies are destroyed "Cube enemy" and currently the system I have in place is on a Game Mode Blueprint, and I think my largest issue is not knowing how to make this blueprint register a destroyed enemy. Any ideas/help?
asked Jul 25 '15 at 10:13 AM in Blueprint Scripting
This is how i did it:
Tell me if something is not clear and i will explain you. I reproduced your idea, so i putted the control of the there is at least 1 enemy on the map in the "Gamemode" blueprint. Where i control if "Lenght>1" is not a error, if you insert "Lenght>0" it will never fires.
Ah, i forgot. The "Damaged" event fires everytimes i click on a cube.
Click the vote button and accept this as answer if is what you was looking for, thank you
It's really simple, make a variable called EnemyAmount.
Whatever the game type you have, just go
Whenever an enemy is spawned -> EnemyAmount == EnemyAmount + 1
Whenever an enemy is killed/defeated/whatever -> EnemyAmount == EnemyAmount - 1
Then, at the end of some loop you may have or wherever logical place it makes sense to put it, have:
If EnemyAmount == 0 -> CombatEnds (this can be a custom event or a function)
If you don't know where to put that ^
You can put it in an Event Tick, though Event Ticks take more ressource than finding a good place to place that If.
ps. "If"s are called "Branch" in Unreal.
answered Jul 26 '15 at 08:18 PM
Follow this question
Once you sign in you will be able to subscribe for any updates here