Skip to content

Instantly share code, notes, and snippets.

@SiarheiPilat
Created August 7, 2020 22:13
Show Gist options
  • Select an option

  • Save SiarheiPilat/9b4dc09940db9e7ced4dfadd0de3dcea to your computer and use it in GitHub Desktop.

Select an option

Save SiarheiPilat/9b4dc09940db9e7ced4dfadd0de3dcea to your computer and use it in GitHub Desktop.
Proper way of reversing animation playback in Unity when using legacy animation system ('Animation' component; when you need to play it backwards).
using UnityEngine;
public class ReverseAnimationLegacy : MonoBehaviour
{
Animation Animation;
void Start()
{
Animation = GetComponent<Animation>();
Animation["walk"].speed = -0.25f;
Animation["walk"].time = Animation["walk"].length;
Animation.Play("walk");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment