How to make it so when you walk in a room, enemies spawn and once killed the door opens?

I already have a basic working system which does what the title says, however a problem I’m having a problem doing this on a larger scale.

I have it so when you walk through this collision box (entrance of the room) it gets the players character location and randomly spawns X amount of enemies near them. And once they are all dead, the door actor gets destroyed. This part works fine however, the problem I’m having is destroying the door actor. Once the first enemy dies it destroys the first door which is fine, however when you go to the next room and the enemies spawn, once you kill them the door does nothing.

I’m not sure what’s happening but i’m assuming it’s only trying to delete Bp_Door 0? So every time the enemies in the room all die its only trying to delete the first door not the rest.

How do I make it so it so it deletes them in an order? Like it till delete the first door once the event is first called and the second time its called it deletes the second door etc etc.

Thanks for any help in advance.

Split your task into smaller tasks.

so make tasks as such:

  • spawn enemies in a room. To do this make spawn points (can be just empty actors with something visible in editor, and hidden in game, watch for collision). Then get all actors of that class, pick random locations spawn enemies there, make sure they spawn in room.
  • when you have that logic to spawn, you need logic that limits spawning to only room you selected. Volumes are best for it. Make volume based actor that checks if spawning is inside of it. Add this logic to spawning
  • now you have spawning for room that you want, Make triggers to check when player entered room (again volume). Spawn when player is in volume
  • last thing is: count how many enemies spawned, and how many player killed. If player killed all of them, you have it all done.

ps.
Watch tutorials about blueprint communication, You will need events and dispatchers and probably blueprint interfaces.

Thanks for the advice, I will be trying this later today. Could you recommend a good tutorial for blueprint communication? Thanks.