Playing Sprite Animations Backwards

Hey everybody. I did a search of the forums and couldn’t find a way to play sprite animations backwards (none of the posted answers worked for me). I then figured out how to make it work, so I figured I’d share, excuse me if this has already been solved elsewhere.

If you have an Animator attached to your GameObject instead of an Animation, meaning what is actually attached to the GameObject is the animation’s controller, simply click on the GameObject in the Project tab. Then, switch over to the new Animator window, added in the 2D update ( the tab next to the Scene tab just above your scene window). Then, click on the Animation bar (the one that fills up as the animation is playing). in the inspector, You should now see “Speed”, “Motion”, “Foot IK” and “Mirror”. From here, simply change the animation’s speed from “1” to “-1” and the animation should play from end to beginning.

I hope this helps, and good luck with your projects.

1 Like

Thanks Ryan!

Thanks.

Yep, way to use when you have a screen fader:

  • keep the original state that runs at 1,
  • duplicate it, rename it and set its speed to -1 so that it runs backwards when you need it,
  • handle to two states by script like the one below and call the FadeIn and FadeOut states from other scripts.

:wink:

using UnityEngine;

public class SceneFader : MonoBehaviour
{
    private Animator animator;
    private int playerIsDeadHashID;

    private void Start()
    {
        animator = GetComponent<Animator>();
        playerIsDeadHashID = Animator.StringToHash("PlayerIsDead");

        GameManager.RegisterSceneFader(this);
    }

    public void SceneFadeIn()
    {
        animator.SetTrigger(playerIsDeadHashID);
    }

    public void SceneFadeOut()
    {
        animator.ResetTrigger(playerIsDeadHashID);
        animator.Play("SceneFadeOut");
    }
}

thanks alot i had same problem now