Playing the animation forward and reverse using animator

Hi Everyone,

I am creating the sprite animation in project, in this sprite animation i am applying on the 3D environment. It has totally 50 sprites, i have done the sprite animation. The problem is i want to reverse this animation like key frames should play from the 50 to 1.

This function available on the animation function, if we give speed as -1 it will play the reverse direction i have dont that too, but i cannot find it on animator. And if i use the animation the i cannot see the sprite in my scene.

So please help me to get rid of this problem.

Thanks.

Each state in the animator controller has a Speed field. Click on the state’s node on the Animator canvas and set Speed to -1.

If you want to play the animation forward and reverse, make two states. On one, set Speed to 1. On the other, set Speed to -1.

2 Likes

i have used the below code:

if(GUI.Button(Rect(0, 0, 100, 30), "2D Anim"))
{

//play forward
anim.speed = 1;
anim.SetBool("2danim", true);
}


if(GUI.Button(Rect(100, 0, 100, 30), "2D Anim"))
{

//play reverse
anim.speed = -1;
anim.SetBool("2danim", false);

}

its working it seems… But after i played the reverse animation if i make the boolean true its taking the long time to play…

here anim notice the animator of the gameobject.