- Home /
Rewind an animator's animation?
I call this code:
GetComponent<Animator>().Play("attack");
How do I get it to stop? Or rewind to the start?
Context: I want to play an archer's attack animation when it attacks. It attacks every 1 second. However, the attack animation is a bit longer, at 1.6 seconds or so. If a new attack is ordered, I want the attack animation to restart from the beginning, rather than waiting for the prior animation to complete first.
I am working with 2D sprites, so I do not want any "blending" or "transitions" or anything like that.
Thanks!
Answer by MauiMauo · Mar 07, 2014 at 04:10 PM
Try using this:
Animator.Play("sameAnimationState", -1, 0f);
Your answer
Follow this Question
Related Questions
2D Animation does not start 1 Answer
How to make more than one animation with the animator? 0 Answers
Baked Animation VS Bezier Tween 0 Answers
why I have to anim.getComponent in update() function when I had done in Start () function 2 Answers
Can the mecanim animators Controller var be set in code? 1 Answer