Opening a Door Relative to the Character Position

i have searched everywhere(or i think so) to make a door open relative to the position of the character. what i mean is the door should not open on my face, rather it should open in the opposite direction. so after scratching my brain for a long time, i came up with this solution. Can anyone suggest a better way to do this or make corrections if i am wrong.


Here is a video

This is my blueprint setup, written in level blueprint. i would be happy if anyone show me how to make a separate blueprint so that i can drag and drop as many doors as i want.
iam a beginner.

1 Like

Look in the Content Examples project from the marketplace, there was something similar in one of the levels IIRC. I would probably do it with one trigger on each side of the door and using the component overlap(right-click on the component variable -> Add event)

If not using two volumes, I would recommend using vector math to determine which direction of the door the player is currently standing at. Use any way you want to activate the door, then when the player interacts with the door (Use Key), run this blueprint.


In the image I run the dot product between the forward vector of the door and a vector from the door to target (player in this case). Dot products are awesome, as they return a value between -1 to 1 if working with unit vectors. (unit vector is a fancy word for a normalized vector, a vector that has a length of 1) You get the value 1 if two vectors are facing the same direction while -1 is opposite. 0 is perpendicular, or “left/right” if you may. Advantage over the multiple volume approach is that you can blend values here.

It does not matter how you decide to orient the door with this approach, it will always understand where the player is.

Dot product is used for a lot of tricks. All from determining how much a light affects a polygon to deciding if the player is within the field of view of an enemy. Make good use of it. :slight_smile:

thanks… that helped

this is my solution, hope this helps :smiley:

I have a question. What is the Overlap Target?
My first guess is Box collider. If so, I GET my “box collider” but cannot connect it to “Get Actor Location”. -Static Mesh component is not compatible with Actor component-

Just use two volumes; one for each side of the door actor. It really is simplest.

The graph shows the blueprint of the door. Self is door. Overlap target is the player or whatever actor is trying to interact with the door.

Yes, it works amazingly accurately, but what if the player turns around. I would like to fix the values so that when turning to accurately determine the position relative to the door.

If you mean that the player must look at the door to interact, then you are probably better off with either using a classic camera trace every tick to determine if you have an object to interact with, or to use your actor or camera forward vector to determine if you are looking in the direction of the door. It would then use the same dot product trick, but with your forward vector and a vector in the direction of the door.