I have a door that a player will be able to open and close. So far everything works just perfekt, though on thing came up that i dont know how to fix or work around.
The door can open 180 degrees at max, now, if some objekt, a player or NPC is in the way, the door should collide with the obejct or NPC, NOT pushing it aside, but instead stop opening at the position of collision.
It should then close, if the player pushes the buitton again.
also it would be nice if the door, once it comes close to an object or NPC, would not just stop immediately, but instead have a cubic behavior. I dont know if this is possible considering performance, since this door will be placed many times in the scene. Though it would be nice, it is not necessary.
I have a screenshot attached of what my BP looks so far.
Hm, you could try creating a second Box Collider that wraps your door (must be a bit thicker). It should be child component of the door itself, so that it moves the same way. Now create an Begin Overlap Event for it and plug it into the “Stop” of your timeline.
Currently i don’t have time to create this on my own, but in theory this should work x)
PS: I don’t know how to create the cubic behaviour though.
Thank you eXi.
No need to spend time on your end, i tried and it actually works great.
Just one thing I have to work around now.
Once the door is open, and I try to close it, it would always stop because it hits the player character and stops, which is fine, but: I cant move out of the way fast enough. Sure I could increase the size of my initial collision box, so I can open the door from further away, but it would cause problems on other ends.
Perfect would be, if the door, once the collision is no longer “true”, means: “on component end overlap”, would start moving again, meaning, it should end its initial animation.
I tried using the “on component end overlap” and it is working, but I am not sure how to plug it in the timeline. When I plug it in start, in would always open the door once the collision is “false”, no matter if I just opened or closed it, which makes perfekt sense.
“Play from start”, “Stop”, “Reverse” and “Reverse from end” all make no sense.
“Set new time” might be an option but I am not sure on how to use it.
You just need to save the state the door was in when it got stopped.
Since it can only be “opening” or “closing”, a bool will work fine.
Create a bool called “bIsOpening”. Since your door is closed first, set it to true in the default settings of the variable. Now take the “set bIsOpening” node 2 times. Plug each behind one of the flip flop outputs. For the “Play” output check the mark so it will be set to true once the door plays the open timeline. Leave to false (unchecked) for the Reverse one.
Now create your END overlap event. Also create a Branch node. Plugin the TRUE ouput of the branch into play and the FALSE one in reverse. Now take the bool again but this time GET it. Plug it into the condition slot of the branch.
Ps: Just thinkung about it. You will want to disable the second collider when the door is fully closed or opened. Otherwise it will open when you run into it and the whole thing breaks the door logik.
It works! Thanks a lot.
Apparently there is no need to disable the second collider though. The door is behaving as it should with two excaptions, not related to your solution.
First, when I open the door, it collides with the player character as intended. Though once I move a little, the door pushes me out of the way, which reuslts in getting pushed off a ledge in my case.
And Second, the “onComponentBeginOverlap”, plugged into the “Stop” of my Timeline, is not working anymore for other than the Player Character. Though I think this is related to the collision settings on the collider within the components tab. It`s set to “custom”. Overlap ALL except Visibility, Camera, Projectile and Destructable.
Here’s my take on what you have. I put a collider on either side of the door (close but not touching it - important) and enable them when the door is moving. The door can be set to close automatically after some time has passed. Blueprint is rather large so not crystal clear but hopefully it’ll help someone.