- Home /
How to stop animation from going past the last frame?
I'm playing an animation in the animator with this script, changing the speed from 1 to -1 through a variable.
if (Input.GetButtonDown("Forward") {
animator.Play("myAnimation", -1);
animator.SetFloat("Speed", 1);
}
if (Input.GetButtonDown("Backward") {
animator.Play("myAnimation", -1);
animator.SetFloat("Speed", -1);
}
Which works fine. Problem is that it when it reaches the start or ending, it seems to continue in time. I.e. if I hold the forward button 1 second after reaching the end, and then start pressing the backward button it will take one second before the animation reaches the "end"-frame and actually starts playing the animation backwards. How can I make it stop at the last / first frame?
Thanks
Answer by vinay_godara · Nov 08, 2020 at 07:54 AM
Still No reply.????? And no way to get it working.
Your answer
![](https://koobas.hobune.stream/wayback/20220612013957im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Dynamically add AnimationState to Controller 0 Answers
Player Starting In Different Positions When Timeline Ends 1 Answer
Is it possible to fire an event on every animation frame? 0 Answers
Animator Controller using Animation Component? 0 Answers
playing one specific animation from animator controller 3 Answers