How do I detect if the player is looking at an object?

Hello! I am new to UE and I am trying to make something happen to an item when a player looks at it and uses an input action. I used a sphere trace for this one and added a custom collision object type. The blueprints seem to be right, and yet nothing seems to happen. Could anyone tell me if there is something i’m missing? I’ll also attach the collision settigs of the item

Is it 3rd person or 1st person?

Hi, you can use dot product and forward vector to determine if something is visible or not against your pawn or another object, I built this little function to know if an actor is visible for a pawn:

3 Likes

Did your object has any scene component? if so, try to look for a variable on it called “Is Visible”. And tell us if that suits your situation.

it’s 1st person

Yeah, “is visible” is set to true

This one seems interesting. I’ll try this one out to see if it works. Thanks in advance!

can you test it during the execution to check if is it on screen?

after a lot of search… i just underestand one thing - we need to use dot product. But how…?
After some experiments i just made this. I don’t know how it works. But it works.
it returns positive number if actor is on … 180 of forvard… if it’s forvard of camera. and negative if backwards.
hope someone will explain why and how dot product is work in mathematics way.
This solution is works so just use it.

1 Like

This works thanks

This is what it looks like in 1st person: