How to get the current motion on Blend tree

I have created an Animator in Unity for my character. For now it is very simple, as I am still learning the basics of animations and blend trees.

However, I have run into an issue when I converted my three walk states into a blend tree. Now I do not know how to differentiate between which motion is playing, to be able to perform some certain logic based on which animation is playing.

My current Animator looks like this:


I have no problem figuring out if the character is in the idle1 state or WalkTree state by doing the following:

animator.GetCurrentAnimatorStateInfo(0).nameHash == Animator.StringToHash("Base Layer.idle1");
animator.GetCurrentAnimatorStateInfo(0).nameHash == Animator.StringToHash("Base Layer.WalkTree");

But how do I figure out whether it is the walk1left, walk1 or walk1right motion that is playing? Or which one is the dominating one? (Might be a more precise question.)

As animator.GetCurrentAnimatorStateInfo(0).nameHash returns the same value, no matter what motion is playing when inside the WalkTree, I cannot use the same methods as shown above anymore.

Any help is much appreciated, thanks!

Blends do just that, blend or combine the animations so all you can get is the value of direction and base whatever you’re doing on that.

Should add:

float curDirection = anim.GetFloat("Direction");