How to stop automatic doors from closing when one player exits but another player is still in the trigger box?

Short Solution:

  • Create a list of Players that overlap the trigger.
  • Add to the list when a new actor overlaps.
  • Remove from the list when actors leave.
  • Only close the door when an Actor leaves, and it is the last.

Long Solution:

  • Create a new Blueprint that inherits from Trigger Box
  • In this BP Assign events to the Dispatchers for OnActorBeginOverlap, and OnActorEndOverlap.
  • In these events, you can track the actors that enter and leave the field, by adding and removing them from a list.
  • You can then create custom EventDispatchers for when an actor is the first to overlap, and the last to unoverlap.
  • You can also create custom EventDispatchers for specific classes, by only holding onto specific class types in your list.

What I would do is create two booleans to keep track of who is and isnt in the box.

Bool PlayerAInBox?
Bool PlayerBIsInBox?

You can check which player enters and exits the box and set their corresponding boolean using on and end overlap.

In event tick you could have a branch saying if ((not)PlayerAInBox AND (not)PlayerBIsInBox) then call close the door.

If you want to compensate for multiple players, an approach could be to make an array of booleans each indexed with the number of players.

Hope that helps.

huh when a player leaving the box why you dont just use the node IsOverlapping Actor with you player list to see if someoneelse is still inside the box.

Very good, glad it worked!
I would also suggest casting the overlapping object to the Player actor before adding or removing from the list, that way if something else overlaps… it won’t stop the door.

I have created basic automatic doors for my game that open on Event ActorBeginOverlap and then close on Event ActorEndOverlap. So when a player enters the trigger box, the doors open and when a player exits the trigger box, the doors close.

The issue is that if Player A enters the trigger box, the doors will open. Player B enters the trigger box and the doors remain open. Player A goes through the door and exits the trigger box and the doors close in Player B’s face. However, what I want is that if any player is still in the trigger box, the doors will not close even when a player exits the trigger box.

Any help with this would be really appreciated! I know there must be some way around this but I haven’t been able to figure it out yet.

Thank you ahead of time!

Thanks for everyone’s answers! They were all helpful. I was able to figure it out by adding actors to an array when they begin overlap and removing them when they end overlap. Then only closing the door when the length of the array = 0.