x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

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

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!

Product Version: UE 4.16
Tags:
more ▼

asked Jul 18 '17 at 09:34 PM in Blueprint Scripting

avatar image

Tudd
3 1 2

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

3 answers: sort voted first

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.

more ▼

answered Jul 18 '17 at 10:11 PM

avatar image

BenVlodgi
2.2k 39 17 52

avatar image Tudd Jul 19 '17 at 04:43 PM

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.

avatar image BenVlodgi Jul 20 '17 at 03:32 PM

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.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

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.

more ▼

answered Jul 19 '17 at 01:29 PM

avatar image

LostScout
135 18 28 36

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

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.

more ▼

answered Jul 19 '17 at 04:30 PM

avatar image

Denis Lambert
310 4 4 8

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question