How to end level after all enemies are destroyed

I’ve seen blueprints on ending a level when things are collected or when a single enemy is destroyed, but I can’t get either way to work with destroying several of the same enemies in a level. How would I go about scripting this in Blueprints?

As a bonus, it would be great if it were possible to do this with them just ragdolling instead of being destroyed, but I can already think of a decent work around if the first way works.

You could do most of this in your GameInstance, you will need a variable to store the number of enemies you currently have remaining. In your enemy blueprint, upon death, you would have to GetGameInstance and cast to your instance, then simply call a similar event to the one in the image to handle logic and level ending.

^^^^This^^

Alright, so I’ve got it mostly figured out, but now it only happens when my variable is set to 1. After I defeat one enemy it’ll end the level but not if I make it 2 (or higher) for example. Is it not refreshing the value? Is there something I have to do with the ReduceEnemyCount event? I know little about custom events

Make sure you’re calling that custom event you’ve created every time an event dies.
Could you maybe post a pic of your network?

I had a lot of trouble figuring out where to put things so I put it all in both the game instance blueprint as well as the enemy character blueprint. It casts to the game instance and everything seems to work regardless, which is why I assume the primary problem is the fact that I don’t have the ReduceEnemyCount event set up to actually do anything. It’s just a a custom event renamed as it is in Spiris’ image, but I didn’t know what to do with it/how to use it. Also, for simplicities sake, I currently just have it set to open my menu instead of using Spiris’ end level stuff

Hey LiuBei, the part after your cast could be removed almost in it’s entirety. In order to properly call the event defined in your game instance you need to drag from the cast node’s As Game Instance pin and call it’s event from there.
You shouldn’t need the enemy count or any of the logic checks in your enemy’s graph.

Ahhhhhh, fantastic! I got it now, thank you!

I hope this helps