How to tell if the player is looking at an object in the center of the screen

Hello, I would like to create a system where when the player looks at the object an outline appears around it.
If the player moves the camera away, the outline loses its intensity until it disappears.
So I would like to know how do I know if the player is looking at the object and how close to the center of the screen this object is.
In this case, I would ultimately need all this to return a unique value like 0 to 1, for me to use in the opacity of the outline.
LineTrace doesn’t work because I would need this fade and not a sudden change, so I have no idea

Dot Product. The range is from -1 to 1. Negative values are behind you.

Image from Gyazo

More info in this post.

1 Like