How to Track and Detect When All Obstacles Are Destroyed in a Brick Breaker Game?

In my brick breaker game, I need a way to track all the obstacles. Once all the obstacles are destroyed, I want to display a ‘Level Complete’ panel. What is the best and most efficient method to track the obstacles without relying on constantly checking and counting them in the Update function?

EntityQuery.IsEmpty()

Use a bool wasQueryEmptyLastFrame to detect when it is the first frame of the query being empty, so that you can trigger the behavior only once on level complete and not during level load or idling on some results screen.

1 Like