My game uses 2D enemies in 3D space. The enemies graphics are obviously flat and are always facing the player. However, I want a different graphic to be displayed for each enemy based on a variable facingDirection which has an enum value corresponding to 8 compass points (N, NE, E, SE, S, etc.) as well as the player’s position in relation to the enemy.
To be more clear: If the enemy is facing north, and the player is standing to the north of the enemy, I want the enemy’s graphic to display its front. If the enemy is facing north and the player is standing to the south of the enemy, I want the player to see its back.
I have an algorithm to calculate this, but it’s somewhat complex and I don’t want to waste time implementing it if there is a built-in function within Unity.
My question is:
Is there such a function in Unity (To find one gameobject’s position in relation to another)?
Any help is appreciated.