Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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
1
Question by Keavon · Dec 07, 2010 at 04:11 AM · animationloopstoprun

Stopping an animation from looping at the end?

Hello! So I basically want to stop an animation from looping, but first I want it to finish it's last run, instead of just stopping wherever it happens to be though it. After this, I need to play a different animation. Could somebody tell me how I might go about scripting this? Thank you! -Keavon

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

3 Replies

· Add your reply
  • Sort: 
avatar image
4

Answer by iaanus · Jun 20, 2013 at 03:09 PM

I have seen others suggesting to use CrossFade/CrossFadeQueued, but they don't get the desired effect. I do not want to cross fade nor blend, I want the looping animation to finish its loop and then play the next animation. Eventually, I found a good way to do it. Just in case anyone needs it, here it is:

 animation["LoopingAnimation"].wrapMode = WrapMode.Once;
 animation.PlayQueued("NextAnimation");

Simple as that. Remember to reset the wrap mode to WrapMode.Loop if you later need to play the looping animation again.

Comment
Add comment · Show 1 · 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 Dimuscul · Jun 16, 2016 at 09:13 AM 0
Share

That does the trick ... but ... maybe something changed on those 3 years ^_^U

If the Animation you are trying to stop was played with PlayQueued, Unity will create a duplicate of that animation, so changing the Warp$$anonymous$$ode of the original will not affect the one you want to make it stop.

 // Global vars
 public Animation myAnim;
 AnimationState myState;

 void PlayEntrance(){
     // Just an entrance animation.
     myAnim.PlayQueued ("Entrance");
     // Then the Idle animation we want to stop later, we save the AnimationState
     myState = myAnim.PlayQueued ("Idle");
 }

 void PlayExit(){
      // We change the warpmode of the saved AnimationState
      myState.wrap$$anonymous$$ode = Wrap$$anonymous$$ode.Once;
      // And put the new animation in.
      myAnim.PlayQueued ("EXit");
 }



avatar image
0

Answer by Justin Warner · Dec 07, 2010 at 05:14 AM

http://unity3d.com/support/documentation/ScriptReference/Animation-clip.html

Work that in, then after the yield, play whatever animation you want...

=) All the best!

Comment
Add comment · Show 1 · 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 Keavon · Dec 07, 2010 at 03:41 PM 0
Share

Thank you, but how do I use that? I am relatively new to Javascripting. First of all, I don't want to make it wait for a certine amount of time, as it appears this example is doing, but then what do I replace with "animation," "clip," "name," and, "length?" Thank you! I would really appreciate it!

avatar image
0

Answer by Cyb3rManiak · May 11, 2011 at 12:05 PM

You can use Animation.CrossFadeQueued to play several animations in a row.

If you don't really understand the basics, I suggest you check out the character-animation example project and the 3d-platform-game tutorial, and read about how the animation in Unity works from the docs.

Basically, if I remember correctly, you do something like:

animation.CrossFadeQueued("shoot", 0.3, QueueMode.PlayNow);
animation.CrossFadeQueued("jump", 0.3, QueueMode.CompleteOthers);
animation.CrossFadeQueued("crawn", 0.3, QueueMode.CompleteOthers);
Comment
Add comment · 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

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

2 People are following this question.

avatar image avatar image

Related Questions

Stop animation when button is released 2 Answers

Animation loop stop? 1 Answer

how to stop animation loop? 1 Answer

The name 'Joystick' does not denote a valid type ('not found') 2 Answers

Loop Animation In Script? 2 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