Friday 15 April 2011

c# - Flipping a 2D Sprite Animation in Unity 2D -



c# - Flipping a 2D Sprite Animation in Unity 2D -

i've got quick question regarding 2d sprite animations haven't been able find answered anywhere:

i have sprite walk animations right. however, want flip animation left when walks left (2d side-scroller).

i can flip sprite itself, using transform.localscale.x, however, flips sprite. not animation clip.

so, while sprite flips, min animation clip begins playing, flips right (as animation clip have right facing sprite).

is way flip sprites in photoshop, or there way in unity?

thanks!

i figured out doing this:

void flip() { // switch way player labelled facing facingright = !facingright; // multiply player's x local scale -1 vector3 thescale = transform.localscale; thescale.x *= -1; transform.localscale = thescale; }

this unity's 2d platformer example.

c# animation unity3d 2d sprite

No comments:

Post a Comment