0
\$\begingroup\$

I have a animation of several parts moving (think bridge) and would like the animation to reverse mid way through if a certain condition is modified (function call). I have the Animation and the AnimationClip which are added via a script.

Currently this is the code:

Animation anim;
public AnimationClip Open; 
// Use this for initialization
void Start () {
    anim = GetComponent<Animation>();
    anim.AddClip (Open, "Open");
    anim.Play ("Open");

}
void Update(){
    Debug.Log ("update");
    if (Input.GetKeyDown ("space")) {
        rev ();
        Debug.Log("reversing");
    }
}
void rev(){
    anim.Rewind()

}

However anim.Rewind() doesn't do what I want it to do it moves the animation back the the first frame rather then slowly move the animation backwards. I know there are some tricks involving the time or by changing the speed but I cannot figure those out either.

\$\endgroup\$
  • \$\begingroup\$ I'm not really that familiar with Unity, but have you tried setting the animation speed to a negative value? \$\endgroup\$ – Alex Apr 30 '15 at 14:31
  • \$\begingroup\$ I looked for that but anim.speed() doesn't seem to exist. \$\endgroup\$ – Thijser Apr 30 '15 at 14:52
  • \$\begingroup\$ I don't think it's a function, rather a property. See here. \$\endgroup\$ – Alex Apr 30 '15 at 14:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.