Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 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
1
Question by tr1stan · Mar 05, 2013 at 07:55 AM · animationmecanimclip

Pause mecanim animation

Is there a way to pause current mecanim animation clip, like we did with Animation.Stop() for the legacy animation system?

Comment
Add comment · Show 1
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 Polymo · Apr 04, 2013 at 08:31 AM 0
Share

I'd like to know that too.

4 Replies

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

Answer by TonyLi · Apr 04, 2013 at 01:50 PM

Have you tried Animator.speed = 0?

Comment
Add comment · Show 3 · 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 Polymo · Apr 05, 2013 at 06:56 AM 0
Share

Thats good, in certain situations. But it affects the overall speed. I guess there's no option to target a single clip/layer?

avatar image TonyLi · Apr 06, 2013 at 11:36 AM 0
Share

Depending on your needs, you could create a Pause bool that transitions to a null state when true and returns to the original state when false.

If you want to pause a layer, you could set (or damp) the layer's weight to 0.

avatar image ina · Jul 23, 2014 at 11:57 AM 0
Share

That doesn't seem to pause, rather stop and rewinds it.

avatar image
2

Answer by rsodre · May 19, 2017 at 06:09 PM

animator.enabled = false;

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 TonyLi · May 19, 2017 at 06:54 PM 0
Share

This is a good solution for Unity 5.6+. For earlier versions, animator.enabled will reset the animator's state.

avatar image
2

Answer by Alond · Jun 13, 2017 at 06:30 PM

If anyone still wondering, I think the best way to pause a specific animation state is to create a float parameter in the animator controller called something like "animSpeed" and assign it to the speed multiplier parameter of the animation state, then you can call animator.SetFloat ("animSpeed", 0f) to pause the animation and animator.SetFloat ("animSpeed", 1f) to resume it. Hope it helps someone. :)

Comment
Add comment · Show 3 · 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 koby234 · Jul 05, 2018 at 02:29 PM 0
Share

How can you access a single animation within the animator?

avatar image vkouroub · Nov 05, 2020 at 08:10 PM 0
Share

Hello. I know it's been years but i'm interested in your idea of pausing the animation state. Can you please clarify how you assign the float parameter to the speed multiplier? Thanks, Bill

avatar image Alond vkouroub · Nov 08, 2020 at 10:30 AM 0
Share

Sure In the Parameters tab of the Animator window, create a new float parameter to control the speed of a certain animation state. Then, in the inspector of this state, enable the checkbox of the Speed - $$anonymous$$ultiplier property and assign the float parameter that you just created. Then control it through script like: Animator anim = GetComponent(); anim.SetFloat("anim_spped", 0); // for pausing anim.SetFloat("anim_spped", 1); // for resu$$anonymous$$g

avatar image
1

Answer by Varaughe · Dec 06, 2015 at 02:46 PM

//You may simply keep the animator playing from the same key time

float freezeTime;
bool freeze = false;//when freeze gets true,freeze animation !
public bool Freeze{
    set{
        freeze = value;
         if(freeze){
            freezeTime = animator.GetCurrentAnimatorStateInfo(0).normalizedTime;
        }
    }
}

Update(){
     if(freeze){
        AnimatorStateInfo stateInfo = animator.GetCurrentAnimatorStateInfo(0);
        animator.Play (stateInfo.nameHash, 0, freezeTime);
    }
}

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

16 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

Related Questions

Possible to play single clips using Mecanim? 0 Answers

Can retargeted mecanim-style animation clips be used with legacy Animation system? 0 Answers

Root motion with attack animation 0 Answers

Reference clip for Additive blending animation in Mecanim 0 Answers

Change the Animation Clip of a Mecanim State 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