Check if sub-state animation is playing

I want to check when my character is playing an animation in a sub-state. My state machines are shown in the pictures.

I am able to check if any animations are playing in the base states through the codes (this works)
if (anim.GetCurrentAnimatorStateInfo(0).IsName("Attack))
{
Debug.Log(“Attack”);
}

However I am unable to access the sub-states using this code (doesn’t work)
if (anim.GetCurrentAnimatorStateInfo(0).IsName(“Attack.AttackRight”))
{
Debug.Log(“AttackRight”);
}

I even tried
if (anim.GetCurrentAnimatorStateInfo(1).IsName(“Attack.AttackRight”))
{
Debug.Log(“AttackRight”);
}

How do I check if my character is playing a sub-state called “AttackRight” which is in the Attack State.


Hey Jeremy have you checked prior threads, I believe this has been asked/answered several times before, though I can’t remember the solution.