Hi all,
I’m trying to animate a door to open when my charcater presses F
I have created a blueprint actor, a door is set as the static mesh and a trigger box is also added.
In the Character’s BP, I have created variable to see if the “F” key is pressed or not:
Just a quick sanity check: with that setup, you would have to press and hold F *before *stepping into the trigger area, then walk into the area while still holding F down in order to get the True result. Did you try that?
The gate works like a coded door, it’s closed by default so the exec pin cant pass through it, when you overlap the box it opens the gate so you can pass through it, and when you leave the box it closes the gate again stopping the flow.
A full rundown of what’s happening
– On tick the code casts to your player and checks if F if pressed or not, that passes to a branch, if F is pressed if checks the local variable “FPressed” to see if that’s true or false, this prevents a constant stream of checks on tick, if that’s true if does nothing, but if it’s false it runs to a sequence which executes code in order, firstly it passes through the gate and executes that code if you’re within the overlap bounds, then it sets the “FPressed” variable to true, this stops the BP from executing more code on that specific key press.