# AddState

> Utility function to add a state to the state machine.

## Definition

* **Type:** Method
* **Namespace:** [UnityEditor.Animations](/engine/6000.0/script-reference/unityeditor/animations.md)
* **Assembly:** UnityEditor

## AddState(string)

Utility function to add a state to the state machine.

```csharp
public AnimatorState AddState(string name)
```

### Parameters

**** (\[string]\(https\://learn.microsoft.com/dotnet/api/system.string)): The name of the new state.

### Returns

| Type                                                                                     | Description                                        |
| ---------------------------------------------------------------------------------------- | -------------------------------------------------- |
| [AnimatorState](/engine/6000.0/script-reference/unityeditor/animations/animatorstate.md) | The AnimatorState that was created for this state. |

### Remarks

The state asset that is created is added as a sub asset of the state machine.  The API returns an [AnimatorState](/engine/6000.0/script-reference/unityeditor/animations/animatorstate.md) which you can use to add transitions.

An example showing usage of this API can be found at the [AnimatorController](/engine/6000.0/script-reference/unityeditor/animations/animatorcontroller.md) page.

## AddState(string, Vector3)

Utility function to add a state to the state machine.

```csharp
public AnimatorState AddState(string name, Vector3 position)
```

### Parameters

**** (\[string]\(https\://learn.microsoft.com/dotnet/api/system.string)): The name of the new state.**** (\[Vector3]\(/engine/6000.0/script-reference/unityengine/vector3)): The position of the state node.

### Returns

| Type                                                                                     | Description                                        |
| ---------------------------------------------------------------------------------------- | -------------------------------------------------- |
| [AnimatorState](/engine/6000.0/script-reference/unityeditor/animations/animatorstate.md) | The AnimatorState that was created for this state. |

### Remarks

The state asset that is created is added as a sub asset of the state machine.  The API returns an [AnimatorState](/engine/6000.0/script-reference/unityeditor/animations/animatorstate.md) which you can use to add transitions.

An example showing usage of this API can be found at the [AnimatorController](/engine/6000.0/script-reference/unityeditor/animations/animatorcontroller.md) page.

## AddState(AnimatorState, Vector3)

Utility function to add a state to the state machine.

```csharp
public void AddState(AnimatorState state, Vector3 position)
```

### Parameters

**** (\[AnimatorState]\(/engine/6000.0/script-reference/unityeditor/animations/animatorstate)): The state to add.**** (\[Vector3]\(/engine/6000.0/script-reference/unityengine/vector3)): The position of the state node.

### Remarks

This function pushes an Undo operation.
