I am making a doom-like first person shooter in 3d world. I am showing enemies as a 2d sprite animated with spritesheet. So i need to determine where the player is regarding to the object.
So if player if front of the object, i will show the front facing sprite animations.
If player is on the right of the object, i will show the right spirtes.
I have followed a video where it is implemented with the camera like this:
var player_forward_direction = -camera.global_transform.basis.z
var npc_forward_direction = global_transform.basis.z
var npc_left_direction = global_transform.basis.x
var left_dot = npc_left_direction.dot(player_forward_direction)
var forward_dot = npc_forward_direction.dot(player_forward_direction)
But the problem here is that if i stand in one place and rotate the camera, this code is impacted. I need to implement this based only on player position, not on camera rotation.
Please help i am total noob in 3d math.