Hi, I am making a race game using sprites and am trying to get sprites animating depending on the angle they are to each other. So if Player two is directly behind player one , player two should see the back of player one.
target = player2.transform.forward - player1.transform.forward;
Angle = Mathf.Atan2(target .x,target .z) * Mathf.Rad2Deg;
That is attached to player one along with a heap of if - else statements to determine what texture the sprite will have depending on the angle.
This works perfectly while player 2 has not turned left or right , but as soon as player two is moved off centre , the angle seems to be wrong ?
Im not sure what I am doing wrong but any advice would be great. sorry if this is hard to understand , it has been a long night.