Opening a door when the player's cursor is over the object, as well as being inside a collision box

I’m trying to figure out how to create a door that can only be opened when the user is looking at the door as well as them being inside the collision box. As of now, the user can open the door whenever they are inside the collision, regardless if they are looking at the object or not, which isn’t what I want.

I’ve tried searching for other examples of people wanting to do this, but I couldn’t find a thing. I know that the overlap section is incorrect and needs to be paired with the begin cursor section for it to work, but when I try to pair them together, the door refuses to open. Any ideas on how to fix this?

Boolean algebra has some use here.

for you best node would be “binary AND”

I don’t see where that is in the list

Drag from any boolean RED pin, and type “AND”
You wil lget and node.

Connect states where trigger is in view AND player is inside overlapping trigger.
Result of that AND will be true only when you inside and see switch.

This is what I’ve currently come up with, but I’ve done something wrong somewhere as the door still won’t open. I’ve only been using Unreal for a few weeks and it’s self taught, so I’m sorry if I’m missing something here which seems rather simple haha

I’ve just done this instead as it seems like the correct way to handle this, but again, it still won’t work.

Getting closer. Placed an event tick onto the branch handling the input, but from there, regardless if the player is looking at the object or not, the door will open if the player is inside the collision box

To check if the object is inside your player’s vision cone (frustum) you must make the dot product between the Direction vector and the Distance vector between the two actors. May sound a bit complicated, but once you read here you can search for a more detailed explanation about the dot product.

Wouldn’t that allow the door to be open even if the door is only a fragment in the player’s frame?

it depends on the acceptable value(degrees) you choose to start the door opening subroutine. When I made myself, I remember the dot product result of 50 degrees was a fine value, caught the actors even if it’s in a fragment of my screen.
In your case you can set a lower value, try testing what is fine for you.

You can add two Scene components, one on each door edges and check if the two are inside your cone vision, making separate dot products calculations

Would OnBeginCursorOver not work for this?

Yep, I just suggested another solution if you want to make it more accurate (will only trigger if the two door’s edges are inside your vision cone). Sorry if that made you confused.

Besides that, how is your actual progress on making it trigger when it’s inside your CollisionBox? Is it working correctly? If not, try posting your code here to see if I can help you. All that solution you are looking for should be easy to make.

This is how it currently looks right now. As of right now, the doors are extremely buggy. Sometimes when you look at a locker door, the one next to it opens, or sometimes the one you’re looking at opens, or nothing opens. No idea why this is happening as it seems to be hit and miss.

Well, looking at this part of the code I can’t figure out why you are facing this issue. This BP you post is your Character’s BP?

Would a line trace be a viable alternative? Whenever the player tries to activate the door just do a trace in the direction the player is facing and see if you hit the door?

This was created inside my locker’s BP, to make it quicker and easier when creating multiple locker objects.

I’ve not done anything with line tracing yet, but from what I’ve seen, that could be a better way to handle all of this if a solution doesn’t get presented soon.

Line tracing is probably your best option. A line tracing function that executes on activate with a blueprint interface to communicate with your door bp. For you door I would have a gate that only executes the door anim on overlap. The line trace will always happen on your activate but won’t do anything unless the player is inside the trigger volume.

Is anyone willing to show a quick example of this? I am currently working on the same thing as it seems really stupid to just have overlap events open doors. I shouldn’t be able to open a door behind me when clearly both my hands are facing forward away from the door holding a gun. Not very accurate imo lol.