- Home /
Can't stop animation
Here is the script:
if (Input.GetMouseButton(0))
{
animation["Animation"].wrapMode = WrapMode.Once;
transform.animation.Play("Animation");
}
It wont stop. only setting it to clampforever will make it stop, but I need to be able to play it again and again. Any Idea why?
I think it'd be better to set the Wrap$$anonymous$$ode in Start() seems excessive to do it every time the animation occurs.
So are you saying if you press the mouse button once it just plays forever? Something isn't adding up here unless you are just holding down the mouse button the whole time in which case playing repeatedly would be the expected behavior.
Or you can use if (Input.Get$$anonymous$$ouseButtonDown(0)) { //animation["Animation"].wrap$$anonymous$$ode = Wrap$$anonymous$$ode.Once; transform.animation.Play("Animation"); }
So if you click, it plays... if you click and hold it should loop
When I tap the mouse button as quickly as I can, It will play about 2-3 times. Its a very very short animation, as it is for just a quick bit of recoil on a gun firing.
Answer by jaxsonp10 · Feb 10, 2014 at 03:20 AM
When I tap the mouse button as quickly as I can, It will play about 2-3 times. Its a very very short animation, as it is for just a quick bit of recoil on a gun firing.
Answer by jaxsonp10 · Feb 10, 2014 at 03:20 AM
OOOOOOH, thank you for pointing that out! I fixed it, thanks
Your answer
![](https://koobas.hobune.stream/wayback/20220613133042im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Animation Rewind not working 1 Answer
Can the animation editor create local rotational data? 3 Answers
Adding animation clips via script 2 Answers
Stop sliding animation 1 Answer