I have animated a needle to go one way and stop when entering a collision box, now i would like it to reverse back to its normal state and stop again
when the player exits the collision box is there anyway of doing this?
#pragma strict
var AnimateNeedle : AnimationClip;
function Start ()
{
GameObject.Find("needle").GetComponent.<Animation>().Stop("needleanimated");
}
function OnTriggerEnter ()
{
GameObject.Find("needle").GetComponent.<Animation>().Play("needleanimated");
}
function OnTriggerExit()
{
}
OctoMan
2
You can reverse animations using the speed value.
Animator anim;
anim.speed = -1;//play animation reversed
anim.speed = 1; // play animation normal