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 xandermacleod · Oct 21, 2013 at 06:32 PM · animationmecanimcheckspecificisplaying

How to check if a specific animation is playing within mecanim

Hi there,

with the old legacy system I know that you can use: Animation.IsPlaying("animName") to return a bool value as to whether or not the specified animation is playing.

Does this same thing exist for mecanim within an Animator?

Specifically I want to do the equivalent of:

if(Blendtree named "Running" is playing) { //Do action }

Can anyone help with this?

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

2 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by darthbator · Oct 22, 2013 at 01:35 AM

It's a little different then it was before (stuff like blend states can really complicate "what is now playing"). You'll want to use this function to get the aimator state info. From there you can call the isName() function or check against the "nameHash" from the animatorStateInfo object returned to you and evaluate your logic against that.

Comment
Add comment · Show 2 · 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 Marzoa · Nov 04, 2014 at 10:43 PM 0
Share

nameHash doesn't return the actual name of the animation, and isName returns a boolean value. I get your point but cannot figure out how to join all those things together to do something.

avatar image Marzoa · Nov 04, 2014 at 10:44 PM 0
Share

O$$anonymous$$, let it be. I found some functional code here:

http://answers.unity3d.com/questions/362629/how-can-i-check-if-an-animation-is-being-played-or.html

avatar image
0

Answer by tyoc213 · Oct 28, 2014 at 06:13 PM

 Animator some = gameObject.GetComponentInChildren<Animator> ();
 AnimationInfo[] ainfo = some.GetCurrentAnimationClipState(0);
 
 
 if(ainfo.Length == 0){
     /*** no animation running***/
 }else{
     for(int idx=0;idx<ainfo.Length;idx++){
     }
 }
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

How to check if an object is playing ANY animation 1 Answer

mecanim animation runs at random speed on iOS 0 Answers

Mecanim and Ragdoll Issues? 2 Answers

Mecanim animation not working correctly after separating from original fbx 0 Answers

Ensure Mecanim registers Boolean before turning off? 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