2.4 - Door With Trigger

Choose your OS:


The BP_Door Blueprint creates a door that opens with a trigger Box Component, and is another example of a Blueprint that might commonly be used in the creation of a game, with script and animation built in that needs no additional setup.

When a player touches the BoxComponent, the Blueprint retrieves the player's location relative to the door and uses this information in conjunction with the Actor's rotation to determine which side of the door the player is on. Then, a Timeline plays that opens the door in the correct direction, so that it swings away from the player.

Event Graph

Click for full size or right-click and Save As.

This Blueprint employs two Timelines : one for opening the door, and one for closing it. When the player first overlaps the Box Component, the Open direction Boolean variable is set depending on which side of the door the player is on. Next, the timeline for opening the door plays. The timeline is connected to a Lerp (Rotator) node, which linearly interpolates between the starting rotation and the desired final rotation. A Select Float node selects the correct final rotation based on the value of Open Direction. This way, the same timeline can be used to open the door in either direction.