Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
2 captures
13 Jun 22 - 14 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
9
Question by Superrodan · Feb 03, 2015 at 10:39 PM · animationanimatorloop

How can I reset a non-looping animation?

Hi there,

I know this is probably a super simple question to answer but I'm close to the functionality I am looking for and can't find the solution I am looking for.

I have created a very simple animation called Roll that rolls a die. I also have a button. I have it so that when you press the button it calls: Animator.Play("Roll")

The first time I tested this, the button worked. It started the roll animation. My problem was the roll animation continued to loop forever. I wanted it to only loop once, and after a google search I found that I needed to uncheck "Loop Time" on my animation. I did that and when I pressed the button it played the animation only once and then stopped in the final frame just like I expected, which was awesome.

The only problem is that after the animation stops the first time I cannot get it to play again by pressing the button again... It just sits at its final frame forever, basically. Is there some sort of reset command I need to call to play the animation again?

Thanks!

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
46
Best Answer

Answer by Superrodan · Feb 03, 2015 at 11:50 PM

Ok, after finally figuring out what to search for I found an answer here:

http://answers.unity3d.com/questions/623878/how-to-restart-mecanim-state-animation-or-play-it.html

What I needed to do was create a script with a reference to the animator that called:

myAnimator.Play("Roll", -1, 0f);

This lets me press the button as many times as I want to restart the animation. I hope this helps someone else!

Comment
Add comment · Show 9 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image CarpetShampooer · May 07, 2015 at 02:44 PM 0
Share

Thank you, your post helped me very quickly. Just wanted to add that if you want to reset the animation on a sprite that only has one animation (like I did), just fill in the first parameter with the sprite's name.

Thanks again, I thought this would take ages to figure out.

avatar image sergiomartin · May 11, 2017 at 01:24 PM 0
Share

Thank you so much! Your post has helped me a lot. I was searching a way to reset some animations and I didn't find until I saw your post.

avatar image TUTOCF · May 12, 2017 at 08:02 PM 0
Share

Thanks you helped me a lot!

avatar image vishalpvr · Jul 21, 2017 at 12:14 PM 0
Share

Thank You ..

Your post sort out my issue....

avatar image marcinrycu · Jan 24, 2021 at 07:14 PM 1
Share

6 years later and it's still helping ! Thanks !

Show more comments

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

29 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Animation keeps playing even with "loop" deactivated. 1 Answer

Loop Time through Script 2D 4.3 1 Answer

Animations in the animator not looping 1 Answer

Loop Animation 1 Answer

How to loop an animation in reverse? 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges