x


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.

more ▼

asked Oct 18 '11 at 11:44 AM

jeff gravatar image

jeff
1 5 5 6

(comments are locked)
10|3000 characters needed characters left

1 answer: sort newest

Figured out the answer .

I needed to be basing the sprite change on the difference between both players Y-Axis Rotation. :)

more ▼

answered Oct 22 '11 at 03:30 AM

jeff gravatar image

jeff
1 5 5 6

(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x1330
x300
x222
x104

asked: Oct 18 '11 at 11:44 AM

Seen: 828 times

Last Updated: Oct 22 '11 at 03:30 AM