# How to end game when all enemies are destroyed?

**URL:** <https://forums.unrealengine.com/t/how-to-end-game-when-all-enemies-are-destroyed/326465>\
**Category:** World Creation\
**Tags:** unreal-engine, level, feedback, UE4, question, Blueprint\
**Created:** [July 25, 2015, 10:13am UTC](https://forums.unrealengine.com/t/how-to-end-game-when-all-enemies-are-destroyed/326465 "2015-07-25T10:13:03Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Santeon](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Santeon](https://forums.unrealengine.com/u/Santeon)\
**Post date:** [July 25, 2015, 10:13am UTC](https://forums.unrealengine.com/t/how-to-end-game-when-all-enemies-are-destroyed/326465/1 "2015-07-25T10:13:03Z")

</div>

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?

 ![51424-12.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/e/3/4/e34131a9f3619e86a07be62af921f10cb831811d.png)

---

<div class="post-metadata">

**Author:** ![Fanto88](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Fanto88](https://forums.unrealengine.com/u/Fanto88)\
**Post date:** [July 25, 2015, 12:12pm UTC](https://forums.unrealengine.com/t/how-to-end-game-when-all-enemies-are-destroyed/326465/2 "2015-07-25T12:12:55Z")

</div>

This is how i did it:

 ![51453-cubeenemy.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/1/5/0/1502f3ee07de8e2b4f9b423ca69c6e15132191a2.png)

 ![51454-gamemode.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/8/3/f/83f5fc539acd6367192580016d3edaa23e5bb4ca.png)

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

---

<div class="post-metadata">

**Author:** ![Santeon](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Santeon](https://forums.unrealengine.com/u/Santeon)\
**Post date:** [July 26, 2015, 12:53am UTC](https://forums.unrealengine.com/t/how-to-end-game-when-all-enemies-are-destroyed/326465/3 "2015-07-26T00:53:52Z")

</div>

Thank you so much for your straight forward answer it’s awesome 😃 currently I have tried to copy this system but part wont fit inside my “Basic Enemy” AKA Cube Enemy Blueprint. Again thx for the help!

 ![51519-13.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/b/e/0/be097cb4b71b7dc53ec2135750619c5ecb2beb2b.png)

 ![51520-14.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/a/3/2/a32b50cae278059627d7703171375e36cf6c51e7.png)

 ![51521-15.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/3/c/c/3ccd967ed9f3d6342ab1085f441adbe4458016ce.png)

---

<div class="post-metadata">

**Author:** ![Fanto88](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Fanto88](https://forums.unrealengine.com/u/Fanto88)\
**Post date:** [July 26, 2015, 1:33am UTC](https://forums.unrealengine.com/t/how-to-end-game-when-all-enemies-are-destroyed/326465/4 "2015-07-26T01:33:52Z")

</div>

Could you tell me what doesn’t work of your script?

The “destroyed” event?

If you put some “print” node we can see where the script stops and then fix it

Ps: could you show me where you call the “apply damage” node?

---

<div class="post-metadata">

**Author:** ![Santeon](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Santeon](https://forums.unrealengine.com/u/Santeon)\
**Post date:** [July 26, 2015, 7:12am UTC](https://forums.unrealengine.com/t/how-to-end-game-when-all-enemies-are-destroyed/326465/5 "2015-07-26T07:12:44Z")

</div>

Down below is what my blueprint used to be; this system did work - taking 1 point each time the enemy dies, but the only problem is that the blueprint would be destroyed with the enemy so it could never count down past 1. I was told to transfer the system to a Game Mode Blueprint so it counts every time a enemy dies without being destroyed with it. Largest problem is it does not register when the enemy dies. I relies you have supplied me with that knowledge and I thank you. But it does currently conflict with my damage system so if there is any way to fix this issue you would be a hero.

 ![51542-example.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/4/d/e/4deac066464938a4cfcd0e9f0a37ecf3ddbd0be1.jpeg)

---

<div class="post-metadata">

**Author:** ![Fanto88](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Fanto88](https://forums.unrealengine.com/u/Fanto88)\
**Post date:** [July 26, 2015, 11:08am UTC](https://forums.unrealengine.com/t/how-to-end-game-when-all-enemies-are-destroyed/326465/6 "2015-07-26T11:08:55Z")

</div>

Could I ask you to upload your project and send me a link for download it? (via Google drive, If you can), so I can take a deeper look

PS: add me on skype so we can talk more freely  
ID: X-BiGBoSs-

---

<div class="post-metadata">

**Author:** ![Santeon](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Santeon](https://forums.unrealengine.com/u/Santeon)\
**Post date:** [July 26, 2015, 7:43pm UTC](https://forums.unrealengine.com/t/how-to-end-game-when-all-enemies-are-destroyed/326465/7 "2015-07-26T19:43:23Z")

</div>

No one found under the name “X-BiGBoSs-”. Also thanks again for the help, i’ll make sure to add you as soon as possible and send you the project! Skype name “Santeon” - Picture is a red, white and black mask

---

<div class="post-metadata">

**Author:** ![Fanto88](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Fanto88](https://forums.unrealengine.com/u/Fanto88)\
**Post date:** [July 26, 2015, 7:53pm UTC](https://forums.unrealengine.com/t/how-to-end-game-when-all-enemies-are-destroyed/326465/8 "2015-07-26T19:53:03Z")

</div>

I have changed my skype id: davide.fanto

Sorry about that

---

<div class="post-metadata">

**Author:** ![Xarahn](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Xarahn](https://forums.unrealengine.com/u/Xarahn)\
**Post date:** [July 26, 2015, 8:18pm UTC](https://forums.unrealengine.com/t/how-to-end-game-when-all-enemies-are-destroyed/326465/9 "2015-07-26T20:18:46Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Santeon](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Santeon](https://forums.unrealengine.com/u/Santeon)\
**Post date:** [July 27, 2015, 5:57am UTC](https://forums.unrealengine.com/t/how-to-end-game-when-all-enemies-are-destroyed/326465/10 "2015-07-27T05:57:42Z")

</div>

sent the invite
