unity play animation backwards code example
Example: unity play animation backwards
using UnityEngine;
using System.Collections;
public class NewBehaviourScript : MonoBehaviour {
Animation anim;
// Use this for initialization
void Start (){
anim = GetComponent ();
anim.Play ("cubeanimation");
}
// Update is called once per frame
void Update () {
if (Input.GetKeyDown (KeyCode.A)) {
// Reverse animation play
anim ["cubeanimation"].speed = -1;
anim ["cubeanimation"].time = anim ["cubeanimation"].length;
anim.Play ("cubeanimation");
}
}
}