- Home /
Animating Sprites
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.
thanks Jeff.
Answer by jeff · Oct 22, 2011 at 03:30 AM
Figured out the answer .
I needed to be basing the sprite change on the difference between both players Y-Axis Rotation. :)
Your answer
Follow this Question
Related Questions
Doom-like Sprite Models 1 Answer
Sprite doesn't flip correctly. 1 Answer
Natural rotation of sun and moon with 2 axis 2 Answers
Angle of object relative to transform of second object 2 Answers
Fading Issue 2 Answers