Determine if an object is behind/infront or to the right/left of the player (relative to where the player is facing) )

I am trying to work out where a given object is in-relation to the players forward facing direction. If the object is to the left of the player, I run specific code that vaguely indicates to the player that the object is to the left (same for the other directions).

The image below is essentially what I want to achieve.
Picture1

I have currently been able to detect if the object is behind/infront of the player using the players and objects locations but unable to differentiate between left/right.

Assistance would be greatly appreciated.

1 Like

The following math should make this easy enough :

Front face : result between -45 to +45
Right face : result between +45 to +135
Left face : result between -45 to -135
Back face : result beyond +135 or beyond -135

5 Likes

OMG, that is PERFECT… Many Thanks!

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