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!

So, I found the answer here: Problem with Hash IDs & End of animation detection - Unity Answers

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.

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”