Opening and closing a door

Good evening everyone!

I’m working on a small video game project, which has to do with a small cabin up in the mountains and the player trying to survive there… and I’m creating this in order to start learning Unreal and get my feet wet. The first problem that I’ve encountered and don’t know how to solve is how to open and close a door via the blueprint editor. I know how to open it, but I can’t figure out how to close it pressing the same button. I have a simple mesh for the door, and a collision box to trigger the event. I’ll attach below the blueprint I’m currently using. I’m hoping you guys know how to solve this petty problem and I can keep moving with the project! :stuck_out_tongue:

What I want to do is to open and close the door at will once the player is inside the trigger box. The sequence is as follows: you press the “open door” key, and the door opens. Press it again and it closes.

I’ve attached two images of the rotation I’m giving to the door and a general picture of the blueprint setup. What do I need to create between the player pressing the keyboard key and the rotation to make it switch between one rotation and the other?

Thanks in advance for your time,

Brais

You need to add in a boolean variable that holds the current state of the door, either open (true) or closed (false). That way before you start your Timeline node you check that state of this variable and either decide to play your timeline from the start or play it in reverse.

Does this make sense?

Once you have that you will need to change how you rotate your door. Instead of giving it an absolute value to rotate towards, you should use the float value from the Timeline to control the degree of rotation on the door, that way when the timeline is in reverse you are feeding it the correct reversing values.

At 36mins into the following video i demonstrate exactly what your after.

[video]Unreal Engine 4 Tutorial (BP) - Communicating between widgets and blueprints with Event Dispatchers - YouTube

Thank you very much for your reply, I can’t watch the video at the moment but I’ll do it as soon as possible. Thanks again! :smiley: