How can I see if a player is looking at a created actor?

A simpler way would be to take the actor’s location minus your character’s location, normalize it and take this normalized vector’s dot with your character’s forward vector. If the dot is greater than 0.9 then your actor is facing the correct way.

The dot’s value can go from (-1) to 1 :

  • 1 means your character is looking perfectly towards the actor
  • 0 means your character is looking in a direction perpendicular to the direction you want him to face
  • (-1) means your character is looking perfectly in the opposite direction

As such, 0.9 is a value that allows for a bit of tolerance but will still allow for pretty accurate results.

1 Like