Avoid door passing through non moving player during open/close

Opening/Closing doors do move through the player, if the player capsule is not moving. For a moving capsule, no intersection happens. I found no collision setting for the capsule, that avoids this behaviour. I found this old thread https://forums.unrealengine.com/deve…standing-still, which gets very physics related.

So I did a solution on my own, no physics needed, which works quite nice which I want to share here. Basically, this uses overlap events for the door with the player and stops the timeline if the player is overlapping and is in a location that will block the door from further movement, i.e. in the current doors movement direction. The timeline playback gets resumed, if the player moves out of the way. The door needs a box collision component for this.

Once the player interacts with the object, an interface function Open And Close is called. If the player is not overlapping at all or overlaps, but is placed so that the door rotation does not get blocked by the capsule, the timeline gets started. A boolean flag indicates, in which direction door movement takes place.

The overlapping state is set by the following part of the blueprint. The InTransition variable is set, if the timeline is started and reset when it has finished.

From the above execution pins, the timeline gets called: if door movement is not blocked, the timeline is started in the direction determined by the ToBeClosed variable.

If the player blocks the movement, the timeline is stopped. The macro “Check Player Block” determines, if the player overlap will block door movement. It checks, if the player is in front of the current movement direction using a simple dot product. Here’s the macro content:

Timeline updates are processed as follows:

Finished: update state by toggling direction and resetting the In Transition variable
Update: just do all the animation needed for the model…

This makes the door stop moving, if the player is blocking, no matter whether the player moves or just stands in front of the door. Once the player moves, the door continues to open/close as well, until the player gives way to the door to complete its cycle. If the player presses the Interaction key again while he is blocking the movement, the timeline gets reversed.

I hope that might be useful. At least it solved my problem and is an easy to implement solution. Let me know, if there are better solutions for this.

Here’s a video link to my dropbox: Dropbox - door-movement-forum-1784524.mp4 - Simplify your life

That’s what I need. But it doesn’t work for me. :frowning:

This seems really good, and perfect for what I need, but likewise I haven’t been able to get it working. Any extra advise you can share?

I have a door that will always swing away from the player too, not sure if this adds extra complications

update: Where my blueprint sits at the moment, but still not working correctly…

Who has a problem when it doesn’t work correctly, make changes to the macros. Replace “right vector” with “forward”. It’s almost a solution because it still has one problem. If player overlapping box collision in door blueprint in front of the door (when dot product is positive) it’s OK and work perfectly, but if the player is standing outside the door and overlapping box collision (when dot product is negative) door won’t open until the player runs out of overlap box collision. Anyway thanks to herb64 for this solution!

Hey there, thanks for reply, have come back to this also to try and get it working again based of your comments. Do you mind elaborating a bit on what you’re sollution is?

I’m having simialr problem I thnk you’re saying, about the player overlapping collision, even though the door should open away from them, so no need to block at this point.

And also still issues where the door will pass through the player.