Detecting when group of objects is destroyed

Ok, let’s say I’m making the classic FPS shooting range tutorial. I have one room for the pistol, one room for the SMG, one room for the rocket launcher, etc.

How can I detect when all the targets in a certain room have been hit, and then open the door to allow the player through? Let’s assume the the targets are individual blueprint classes (so they can spawn particle effects and such when they die.)

Sure man , there are a lot of ways to do this.

  1. probably you place these targets in the editor, so in your level blueprint (you can select and add reference to them) or in an actor blueprint (you can an array of actor reference type ) you can :
    Use the “cast to” in case of failure to casting , the actor is not anymore. so if all the cast to , get fail , all the actor was destroyed.
    If you dont want to destroy all these targets , but you only change theyr static meshes and animation and stuff…
    You use the cast to , to read inside them , a variable that you have to set up when the target get “killed”, and restarted.

2)You can also use all actor of class , that return you a vector of a specific type of actor, so if this array return you with 0 of 10, this mean that the target was destroyed.
We can keep going but , try one of these.

As Est_Engine said, there are many ways to do this. There’s no one right way to do it. You need to evaluate your needs with perhaps an eye to the future.

I’d create some sort of Manager that is able to track all the objects it’s concerned about. It could listen to the objects OnDestroyed event and remove it from the list. If the list is zero it could then perform an action. The manager is then a re-useable object that you can use all around your levels.

As my game grows, I could give this other manager other responsibilities. Spawn more objects? Perform more than one action? Perform random actions?

I’d personally put this logic in C++ but stick to Blueprints if that’s what you know. But take a step back and think about how you would like to use this functionality as a level designer in a user friendly manner. Then make the details happen.

Thanks. I think I just have a weird situation. I was able to accomplish what I wanted using a blueprint interface between the targets and a per-room master blueprint.

Doing it this way, I have one blueprint that I can place anywhere that will generate the targets randomly, and automatically “link” them to the master blueprint which will keep track of each room separately.