# IsName(string)

> Checks if name matches the name of the active state in the state machine.

## Definition

* **Type:** Method
* **Namespace:** [UnityEngine](/engine/6000.5/script-reference/unityengine.md)
* **Assembly:** UnityEngine.AnimationModule

```csharp
public bool IsName(string name)
```

### Parameters

**** (\[string]\(https\://learn.microsoft.com/dotnet/api/system.string)): The name to check.

### Returns

| Type                                                          | Description                                                      |
| ------------------------------------------------------------- | ---------------------------------------------------------------- |
| [bool](https://learn.microsoft.com/dotnet/api/system.boolean) | True if the animation state has the given name, false otherwise. |

### Remarks

The name should be in the form *Layer.Name* or *Layer.SubStateMachine.Name*. For example, `Base.Idle` or `Base.RunSM.JogForward`.

This method calls [Animator.StringToHash](/engine/6000.5/script-reference/unityengine/animator/stringtohash.md) on the name parameter and compares it to [AnimatorStateInfo.shortNameHash](/engine/6000.5/script-reference/unityengine/animatorstateinfo/shortnamehash.md) and [AnimatorStateInfo.fullPathHash](/engine/6000.5/script-reference/unityengine/animatorstateinfo/fullpathhash.md) internally. If you call this method often, consider precomputing the hash of the name to improve performance.

```csharp
// This script demonstrates how to check if the current state of an Animator has a specific name.

using UnityEngine;

[RequireComponent(typeof(Animator))]
public class AnimatorStateInfoIsNameExample : MonoBehaviour
{
    // The Animator component on the GameObject this script is attached to.
    Animator m_Animator;

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

    void Update()
    {
        // If the current state has the specified name, log a message.
        var stateInfo = m_Animator.GetCurrentAnimatorStateInfo(0);
        if (stateInfo.IsName("Base.Idle"))
        {
            Debug.Log($"Currently in state Base.Idle.");
        }
    }
}
```

Additional Resources: [Animator.StringToHash](/engine/6000.5/script-reference/unityengine/animator/stringtohash.md) , [AnimatorStateInfo.IsTag](/engine/6000.5/script-reference/unityengine/animatorstateinfo/istag.md).
