- Home /
Question by
Mattivc · Apr 07, 2010 at 03:31 PM ·
animationjavascript-specific
Reverse animation at the point it stopped playing
I want to have a animation play when a button is pressed down. And then have the animation reverse from the point it stopped when the button is released, how can i achive this using javascript?
Comment
Best Answer
Answer by e-bonneville · Apr 07, 2010 at 03:39 PM
Try this:
function Update () { if (Input.GetButton ("Fire2") { animation.Play ("FunkyThing"); }
if (Input.GetButton ("Fire1") {
animation["FunkyThing"].speed = -1.0;
}
}
Play the animation with right-click
or ctrl
. To reverse the animation, press spacebar
or left-click
.
I found this helped shed a bit more light on the reversing animations: http://answers.unity3d.com/questions/16198/animation-reverse-for-movement.html