# GetBool

> Returns the value of the given boolean parameter.

## Definition

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

## GetBool(string)

Returns the value of the given boolean parameter.

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

### Parameters

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

### Returns

| Type                                                          | Description                 |
| ------------------------------------------------------------- | --------------------------- |
| [bool](https://learn.microsoft.com/dotnet/api/system.boolean) | The value of the parameter. |

### Remarks

Return the current state of a bool parameter within the Animator Controller. Use the parameter’s name or ID to search for the appropriate one.

### Examples

```csharp
//Attach this script to a GameObject with an Animator component attached.
//For this example, create parameters in the Animator and name them “Crouch” and “Jump”
//Apply these parameters to your transitions between states

//This script allows you to set a Boolean Animator parameter on and set another Boolean parameter to off if it is currently playing. Press the space key to do this.

using UnityEngine;

public class AnimatorGetBool : MonoBehaviour
{
    //Fetch the Animator
    Animator m_Animator;
    // Use this to decide if the GameObject can jump or not
    bool m_Jump;

    void Start()
    {
        //This gets the Animator, which should be attached to the GameObject you are intending to animate.
        m_Animator = gameObject.GetComponent<Animator>();
        // The GameObject cannot jump
        m_Jump = false;
    }

    void Update()
    {
        //Press the space bar to enable the "Jump" parameter in the Animator Controller
        if (Input.GetKey(KeyCode.Space))
        {
            //Set the "Jump" parameter in the Animator Controller to true
            m_Animator.SetBool("Jump", true);
            //Check to see if the "Crouch" parameter is enabled
            if (m_Animator.GetBool("Crouch"))
            {
                //If the "Crouch" parameter is enabled, disable it as the Animation should no longer be crouching
                m_Animator.SetBool("Crouch", false);
            }
        }
        //Otherwise the "Jump" parameter should be false
        else m_Animator.SetBool("Jump", false);

        //Press the down arrow key to enable the "Crouch" parameter
        if (Input.GetKey(KeyCode.DownArrow))
            m_Animator.SetBool("Crouch", true);
        else
            m_Animator.SetBool("Crouch", false);
    }
}
```

## GetBool(int)

Returns the value of the given boolean parameter.

```csharp
public bool GetBool(int id)
```

### Parameters

**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): The parameter ID.

### Returns

| Type                                                          | Description                 |
| ------------------------------------------------------------- | --------------------------- |
| [bool](https://learn.microsoft.com/dotnet/api/system.boolean) | The value of the parameter. |

### Remarks

Return the current state of a bool parameter within the Animator Controller. Use the parameter’s name or ID to search for the appropriate one.

### Examples

```csharp
//Attach this script to a GameObject with an Animator component attached.
//For this example, create parameters in the Animator and name them “Crouch” and “Jump”
//Apply these parameters to your transitions between states

//This script allows you to set a Boolean Animator parameter on and set another Boolean parameter to off if it is currently playing. Press the space key to do this.

using UnityEngine;

public class AnimatorGetBool : MonoBehaviour
{
    //Fetch the Animator
    Animator m_Animator;
    // Use this to decide if the GameObject can jump or not
    bool m_Jump;

    void Start()
    {
        //This gets the Animator, which should be attached to the GameObject you are intending to animate.
        m_Animator = gameObject.GetComponent<Animator>();
        // The GameObject cannot jump
        m_Jump = false;
    }

    void Update()
    {
        //Press the space bar to enable the "Jump" parameter in the Animator Controller
        if (Input.GetKey(KeyCode.Space))
        {
            //Set the "Jump" parameter in the Animator Controller to true
            m_Animator.SetBool("Jump", true);
            //Check to see if the "Crouch" parameter is enabled
            if (m_Animator.GetBool("Crouch"))
            {
                //If the "Crouch" parameter is enabled, disable it as the Animation should no longer be crouching
                m_Animator.SetBool("Crouch", false);
            }
        }
        //Otherwise the "Jump" parameter should be false
        else m_Animator.SetBool("Jump", false);

        //Press the down arrow key to enable the "Crouch" parameter
        if (Input.GetKey(KeyCode.DownArrow))
            m_Animator.SetBool("Crouch", true);
        else
            m_Animator.SetBool("Crouch", false);
    }
}
```
