- Home /
Animation.Rewind() does nothing
here is a sample of my code:
void Update () {
if(Input.GetButtonDown("Fire2")){
if(state){
this.animation.Play();
state=false;
}
else{
this.animation.Rewind();
state=true;
}
}
}
I'm just trying to make the animation active forward when I press alt, and after that press alt again to make it rewind (play backwards).
the play goes just right, but once I press alt again, nothing happens, if I press alt again, the animation's just starts from the beginning once again.
what should I do?
Comment
Best Answer
Answer by dood2 · Aug 20, 2013 at 07:06 AM
Change "blah" to your animation name.
var playForward : boolean = false;
function Start ()
{
animation["blah"].enabled = true;
animation["blah"].speed = 0.0;
animation["blah"].weight = 1.0;
animation["blah"].wrapMode = WrapMode.ClampForever;
}
function Update ()
{
if(Input.GetButtonDown("Fire2"))
{
playForward = !playForward;
animation["blah"].speed = playForward ? 1.0 : -1.0;
animation["blah"].normalizedTime = Mathf.Clamp01(animation["blah"].normalizedTime);
}
}