Animator Play Unity 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<Animation> ();
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");
}
}
}

Comments

Popular posts from this blog

Converting A String To Int In Groovy

"Cannot Create Cache Directory /home//.composer/cache/repo/https---packagist.org/, Or Directory Is Not Writable. Proceeding Without Cache"

Android How Can I Convert A String To A Editable