Question by
jordomanoa · Nov 18, 2015 at 03:39 PM ·
animationunity 5ontriggerexitreverse
Animation play in reverse OnTriggerExit
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()
{
}
needle.png
(114.2 kB)
Comment
Answer by OctoMan · Nov 18, 2015 at 04:34 PM
You can reverse animations using the speed value.
Animator anim;
anim.speed = -1;//play animation reversed
anim.speed = 1; // play animation normal
Your answer
![](https://koobas.hobune.stream/wayback/20220612045536im_/https://answers.unity.com/themes/thub/images/avi.jpg)