Hi,everyone!
I’m working on a 2D RPG game.The walking animation is based on the skeleton model.Now I had done the walking left animation,and I want to reuse it on the walking right by rotate it.
I want to rotate the animation when the rightarrow key pushed,and I want to rotate only once.
Here is my code:
if ( velocity.x < 0 ) // walk left
{
velocity *= walkSpeed; // move left based on walk speed
ruyinAnimation.CrossFade("walk_left");
}
if ( velocity.x > 0 ) // walk right
{
velocity *= walkSpeed; // move right based on walk speed
transform.Rotate(0,180, 0);
ruyinAnimation.CrossFade("walk_left");
}
if( velocity.x == 0 && moveDirection == 1 )
{
ruyinAnimation.CrossFade("stand_left");
}
if( velocity.x == 0 && moveDirection == 0 )
{
ruyinAnimation.CrossFade("stand_left");
}
When I pushed the rightarrow key,the animation rotate again and again…
I just want it rotate once…
Will somebody please help me?
PS:sorry for my poor English…