# AddMotion

> Utility function that creates a new state with the motion in it.

## Definition

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

## AddMotion(Motion)

Utility function that creates a new state with the motion in it.

```csharp
public AnimatorState AddMotion(Motion motion)
```

### Parameters

**** (\[Motion]\(/engine/6000.0/script-reference/unityengine/motion)): The Motion that will be in the AnimatorState.

### Returns

| Type                                                                                     | Description |
| ---------------------------------------------------------------------------------------- | ----------- |
| [AnimatorState](/engine/6000.0/script-reference/unityeditor/animations/animatorstate.md) |             |

### Remarks

The state asset that is created is added as a sub asset of the state machine to which it is added. This function pushes an Undo operation.

## AddMotion(Motion, int)

Utility function that creates a new state with the motion in it.

```csharp
public AnimatorState AddMotion(Motion motion, int layerIndex)
```

### Parameters

**** (\[Motion]\(/engine/6000.0/script-reference/unityengine/motion)): The Motion that will be in the AnimatorState.**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): The layer where the Motion will be added.

### Returns

| Type                                                                                     | Description |
| ---------------------------------------------------------------------------------------- | ----------- |
| [AnimatorState](/engine/6000.0/script-reference/unityeditor/animations/animatorstate.md) |             |

### Remarks

The state asset that is created is added as a sub asset of the state machine to which it is added. This function pushes an Undo operation.
