# AddStateMachine

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

## Definition

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

## AddStateMachine(string)

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

```csharp
public AnimatorStateMachine AddStateMachine(string name)
```

### Parameters

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

### Returns

| Type                                                                                                   | Description                                                                                                                             |
| ------------------------------------------------------------------------------------------------------ | --------------------------------------------------------------------------------------------------------------------------------------- |
| [AnimatorStateMachine](/engine/6000.5/script-reference/unityeditor/animations/animatorstatemachine.md) | The newly created [AnimatorStateMachine](/engine/6000.5/script-reference/unityeditor/animations/animatorstatemachine.md) state machine. |

### Remarks

The state machine asset that is created is added as a sub asset of the state machine.

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

## AddStateMachine(string, Vector3)

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

```csharp
public AnimatorStateMachine AddStateMachine(string name, Vector3 position)
```

### Parameters

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

### Returns

| Type                                                                                                   | Description                                                                                                                             |
| ------------------------------------------------------------------------------------------------------ | --------------------------------------------------------------------------------------------------------------------------------------- |
| [AnimatorStateMachine](/engine/6000.5/script-reference/unityeditor/animations/animatorstatemachine.md) | The newly created [AnimatorStateMachine](/engine/6000.5/script-reference/unityeditor/animations/animatorstatemachine.md) state machine. |

### Remarks

The state machine asset that is created is added as a sub asset of the state machine.

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

## AddStateMachine(AnimatorStateMachine, Vector3)

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

```csharp
public void AddStateMachine(AnimatorStateMachine stateMachine, Vector3 position)
```

### Parameters

**** (\[AnimatorStateMachine]\(/engine/6000.5/script-reference/unityeditor/animations/animatorstatemachine)): The state machine to add.**** (\[Vector3]\(/engine/6000.5/script-reference/unityengine/vector3)): The position of the state machine node.

### Remarks

This function pushes an Undo operation.
