How to end level when all enemies are destroyed

  • Create a counter in your Game State and create an Event called End Game or something.
  • In your Enemies’ Begin Play tell your Game state to register the enemy. The registration itself should increment the counter and bind a an event OnDeath that decrements the counter when that enemy dies. When decrementing you should check if it is 0 and if so call the End Game event.
  • Wherever you handle your UI on begin play bind to the End Game even from the Game Mode. What you bind should tell your HUD to show the “You Win” screen.

It looks complex but it’s not.