- Home /
Mecanim animation auto playing when "Play Automatically" not checked?
I have an anim I made using Unity's animation tools. The animation changes the Y value of the rect transform to move a UIPanel down. The animation plays fine, but I can't get it to stop playing automatically. I have "Play Automatically" unchecked, is there another place to look if my animation is playing automatically when the scene loads?
Here are my settings:
Answer by mcroswell · Sep 17, 2014 at 05:56 AM
So, the simple answer is below, but first read this...
Unity uses two basic ways to do animation. The old way was that you put the Animat*ion component into the object you wanted to animate. For complex systems you'd blend and mix Animation Clips in code. The new way is to put an Animator* Component and it references the Animation Clip.
Now, it is typical to use the Animation with Clip(s) by itself or the Animator with Controller, but not both.
For now, just check off the Animation component and try it. You can double click on the Animator Controller PanelSearchingForMatch and see if the transitions are set up how you expect. Notice the Animator Controller would use the animation clip ShowSearchingForMatch.
The other option would be just to use the Animation component by itself. Uncheck or remove the Animator Controller component.
Either way, you should go find your Animation (not the Animator Controller) in the Project View. Click on it and uncheck the loop. Here's one I did (just an elevator that goes up and stops):
Finally, there are times when it does make sense to have say an Animation component in a child game object. But, for most cases it really makes sense to use just the Animator Controller and have it reference all the Animations and not use the Animation component explicitly. Or use the Animation component by itself (the old legacy way) and switch clips. I suggest not using both approaches in the same game object.
Fantastic @mcroswell. Thank you for going above and beyond by explaining the differences between animation and animator (something that has been really confusing to me in all of the videos I've watched), which is newer, how I could use either and which is best to use. I now have this working as expected.
You're welcome @omatase. Unity really needs a write-up on this since it is kind of history-based reasoning. I has another motivation to help you to: I am, yet again, editing my Animation and $$anonymous$$ecanim chapters in a book, and needed to get refreshed. So...
Thank you, too,
-$$anonymous$$ike
Answer by Leslie-Young · Oct 30, 2014 at 09:14 PM
I created an empty state and made it default (right-click on state for option) so that the animation do not auto-play. I named it "Idle".
When I need to play the animation I created I simply call Animator.Play with the name of the state that has that clip. To stop the animation I call Animator.Play("Idle");
Thank you so much Leslie. I spend like an hour looking for this answer. I think the documentation is not explicit enough on this subject...
Your answer
![](https://koobas.hobune.stream/wayback/20220613163156im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Add more bones to skeleton - vertebraes definition...? 0 Answers
Mecanim Animate Physics - When to use? 0 Answers
Tweaking a Walk Cycle 0 Answers
Mecanim animation clip mask 1 Answer
why playing animation resets object's transform in Mecanim? 1 Answer