Opening a door only if I point the cursor at it

SOLVED
I realised that I just want to open/close door with LMB, no need for key E. So I just fixed it by myself. :smiley:

Hi. First of all, I’m using UE4.25.4.

I have a blueprint that works properly - if I press E, door opens/closes and it plays sound. This all works well. But I want to add one thing. You can press E while standing on the opposite side of map and door is still opening/closing. I want this to be able only if I’m pointing at the door object. What should I do to make this work? Can I use OnBeginCursorOver? Thanks for replies!

1 Like

The usual way people do this is using an overlap volume. When the player overlaps, enable input, end overlap, disable input.

That works fine, apart from one thing: you can open the door with your butt :slight_smile:

If you really want to be sure the door only opens when the player is looking at it, then you need a line trace

Do you mean remotely control the door , but only under the condition when your mouse is pointing at the door?
If so, Yes, you can use on mouse over event.
Try create a new Boolean variable, name it CanOpen, then on mouse over set it to true, on mouse leave set it to false.
right behind your keyboard event, do a if branch to check the Boolean. If true open, if false do nothing.
So when your mouse not on the door, the bool won’t be true, and of course won’t open.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.