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 JoRouss · Apr 09, 2014 at 08:49 AM · animatorhash

How to get Animator's Layer --> Sub-State --> State namehash?

I'm using the following structure:

(Layer) "Base Layer" --> (Sub-State) "Jump_Fall_Roll" --> (State) "Roll"

 static int rollState = Animator.StringToHash("What to put here??");

 private Animator anim;
 private AnimatorStateInfo currentBaseState;

 void Start ()
 {
     anim = GetComponent<Animator>();
 }

 void FixedUpdate ()
 {
     currentBaseState = anim.GetCurrentAnimatorStateInfo(0);

     if (currentBaseState.nameHash == rollState) {
         Debug.Log ("ROLL nameHash worked"); //Not working
     }
     if (currentBaseState.IsName("Roll")) {
         Debug.Log ("ROLL IsName worked"); //Working.......
     }
 }

I tryed every possible combinaison of parents/states for the nameHash, but it never worked...

The name should be in the form Layer.Name, for example "Base.Idle".

AnimatorStateInfo.IsName doc from Unity

So, why is my first case not working? And how can the second case work??

I'm really confused.

Thank you!

Comment
Add comment · Show 2
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 deram_scholzara · Dec 16, 2014 at 11:55 PM 0
Share

I'm having this exact same problem - did you ever find a solution?

avatar image JoRouss · Dec 17, 2014 at 08:42 AM 0
Share

Yes, I made this Stackoverflow post too : http://stackoverflow.com/questions/22956518/unity3d-how-to-get-animators-layer-sub-state-state-namehash/22972594#22972594 Thank you :)

2 Replies

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

Answer by deram_scholzara · Dec 17, 2014 at 12:20 AM

So, I found the answer here: http://answers.unity3d.com/questions/826835/problem-with-hash-ids-end-of-animation-detection.html

Apparently Unity just hasn't documented getting hashes for States in SubStates.

What you have to do is replace the layer portion with your SubState node name. In your case, this would end up being "Jump_Fall_Roll.Roll". You just leave out the "Base Layer" part completely.

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
avatar image
0

Answer by sergiusz308 · Nov 30, 2020 at 12:44 AM

In 2020 things are little bit different though.

To get substate full-hash you need to provide:

(layer name).(sub state name).(state name within sub state)

For example, considering you have "Base Layer" and then "jumping" substate and inside you have "jumping loop" state. Your path would be:

"base layer"."jumpin"."jumpin loop"

S.

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

23 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

Related Questions

Animation From blender to Unity Animator - Import Error 1 Answer

Namehash BLENDTREE in Substate 0 Answers

Cloud recognition in Vuforia 0 Answers

How to controll parameters in animator using javascript 1 Answer

UnityEngine.AnimatorStateInfo.nameHash' is obsolete: "Use AnimatorStateInfo.fullPathHash instead." 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