# Animation

Kind: Class · Namespace: Sansar.Simulation · Assembly: Sansar.Simulation.dll · Script API 47.10.0

<div class="api-meta">
<span class="api-kind api-kind-class" data-pagefind-filter="kind:Class">Class</span>
<span data-pagefind-filter="namespace:Sansar.Simulation">Namespace <a href="/scripting/api/sansar.simulation"><code>Sansar.Simulation</code></a></span>
<span>Inherits <a href="/scripting/api/sansar.script/instanceinterface">Sansar.Script.InstanceInterface</a></span>
</div>

<span id="T:Sansar.Simulation.Animation"></span>

Represents a scriptable Animation node.

```csharp
public class Animation : Sansar.Script.InstanceInterface
```

## Members at a glance

| Kind | Members |
|---|---|
| **Methods** | [GetFrameCount](#getframecount) · [GetName](#getname) · [GetParameters](#getparameters) · [IsPaused](#ispaused) · [JumpToFrame](#jumptoframe) · [Pause](#pause) · [Play](#play) · [Reset](#reset) · [SetParameters](#setparameters) |

## Methods

### GetFrameCount

<div class="api-card">
<span id="M:Sansar.Simulation.Animation.GetFrameCount"></span>
<span id="M:Sansar.Simulation.Animation.GetFrameCount()"></span>

```csharp signature
public int GetFrameCount()
```

Gets the frame count of the animation

**Returns:** [int](https://learn.microsoft.com/dotnet/api/system.int32) — Returns the total number of frames in the animation.

</div>

### GetName

<div class="api-card">
<span id="M:Sansar.Simulation.Animation.GetName"></span>
<span id="M:Sansar.Simulation.Animation.GetName()"></span>

```csharp signature
public string GetName()
```

Gets the name of the animation

**Returns:** [string](https://learn.microsoft.com/dotnet/api/system.string) — Returns the name of the animation.

</div>

### GetParameters

<div class="api-card">
<span id="M:Sansar.Simulation.Animation.GetParameters"></span>
<span id="M:Sansar.Simulation.Animation.GetParameters()"></span>

```csharp signature
public AnimationParameters GetParameters()
```

Gets the last applied parameters for the animation

**Returns:** [AnimationParameters](/scripting/api/sansar.simulation/animationparameters) — Returns the current parameters.

</div>

### IsPaused

<div class="api-card">
<span id="M:Sansar.Simulation.Animation.IsPaused"></span>
<span id="M:Sansar.Simulation.Animation.IsPaused()"></span>

```csharp signature
public bool IsPaused()
```

Gets whether or not the animation is paused.

**Returns:** [bool](https://learn.microsoft.com/dotnet/api/system.boolean) — A bool value indicating the pause state.

</div>

### JumpToFrame

<div class="api-card" id="jumptoframe-int32">
<span id="M:Sansar.Simulation.Animation.JumpToFrame(System.Int32)"></span>

```csharp signature
public void JumpToFrame(int frame)
```

Jump to frame. The animation will be set to the specified frame, and paused.

| Parameter | Type | Description |
|---|---|---|
| `frame` | [int](https://learn.microsoft.com/dotnet/api/system.int32) | Frame to jump to. |

<details class="api-remarks"><summary>Remarks</summary>

To block until the method returns pass this to [`ScriptBase.WaitFor`](/scripting/api/sansar.script/scriptbase#waitfor-func-2) in a coroutine.

</details>

</div>

<div class="api-card" id="jumptoframe-int32-operationcomplete">
<span id="M:Sansar.Simulation.Animation.JumpToFrame(System.Int32,Sansar.Script.ScriptBase.OperationComplete)"></span>
<div class="api-badges"><span class="api-badge api-deprecated">Deprecated</span></div>

```csharp signature
[System.Obsolete("Deprecated. Use the Action<> overload", false)]
public ulong JumpToFrame(
    int frame,
    Sansar.Script.ScriptBase.OperationComplete handler
)
```

Jump to frame. The animation will be set to the specified frame, and paused.

| Parameter | Type | Description |
|---|---|---|
| `frame` | [int](https://learn.microsoft.com/dotnet/api/system.int32) | Frame to jump to. |
| `handler` | [Sansar.Script.ScriptBase.OperationComplete](/scripting/api/sansar.script/scriptbase.operationcomplete) | Handler to be called when the event completes. |

**Returns:** [ulong](https://learn.microsoft.com/dotnet/api/system.uint64) — Returns an internal event id.

<details class="api-remarks"><summary>Remarks</summary>

To block until the method returns pass this to [`ScriptBase.WaitFor`](/scripting/api/sansar.script/scriptbase#waitfor-func-2) in a coroutine.

</details>

</div>

<div class="api-card" id="jumptoframe-int32-action">
<span id="M:Sansar.Simulation.Animation.JumpToFrame(System.Int32,System.Action{Sansar.Script.OperationCompleteEvent})"></span>

```csharp signature
public void JumpToFrame(
    int frame,
    Action<Sansar.Script.OperationCompleteEvent> handler
)
```

Jump to frame. The animation will be set to the specified frame, and paused.

| Parameter | Type | Description |
|---|---|---|
| `frame` | [int](https://learn.microsoft.com/dotnet/api/system.int32) | Frame to jump to. |
| `handler` | [Action&lt;Sansar.Script.OperationCompleteEvent&gt;](https://learn.microsoft.com/dotnet/api/system.action-1) | Handler to be called when the event completes. |

<details class="api-remarks"><summary>Remarks</summary>

To block until the method returns pass this to [`ScriptBase.WaitFor`](/scripting/api/sansar.script/scriptbase#waitfor-func-2) in a coroutine.

</details>

</div>

### Pause

<div class="api-card" id="pause-noargs">
<span id="M:Sansar.Simulation.Animation.Pause"></span>
<span id="M:Sansar.Simulation.Animation.Pause()"></span>

```csharp signature
public void Pause()
```

Pauses the animation.

<details class="api-remarks"><summary>Remarks</summary>

To block until the method returns pass this to [`ScriptBase.WaitFor`](/scripting/api/sansar.script/scriptbase#waitfor-func-2) in a coroutine.

</details>

</div>

<div class="api-card" id="pause-operationcomplete">
<span id="M:Sansar.Simulation.Animation.Pause(Sansar.Script.ScriptBase.OperationComplete)"></span>
<div class="api-badges"><span class="api-badge api-deprecated">Deprecated</span></div>

```csharp signature
[System.Obsolete("Deprecated. Use the Action<> overload", false)]
public ulong Pause(Sansar.Script.ScriptBase.OperationComplete handler)
```

Pauses the animation.

| Parameter | Type | Description |
|---|---|---|
| `handler` | [Sansar.Script.ScriptBase.OperationComplete](/scripting/api/sansar.script/scriptbase.operationcomplete) | Handler to be called when the event completes. |

**Returns:** [ulong](https://learn.microsoft.com/dotnet/api/system.uint64) — Returns an internal event id.

<details class="api-remarks"><summary>Remarks</summary>

To block until the method returns pass this to [`ScriptBase.WaitFor`](/scripting/api/sansar.script/scriptbase#waitfor-func-2) in a coroutine.

</details>

</div>

<div class="api-card" id="pause-action">
<span id="M:Sansar.Simulation.Animation.Pause(System.Action{Sansar.Script.OperationCompleteEvent})"></span>

```csharp signature
public void Pause(
    Action<Sansar.Script.OperationCompleteEvent> handler
)
```

Pauses the animation.

| Parameter | Type | Description |
|---|---|---|
| `handler` | [Action&lt;Sansar.Script.OperationCompleteEvent&gt;](https://learn.microsoft.com/dotnet/api/system.action-1) | Handler to be called when the event completes. |

<details class="api-remarks"><summary>Remarks</summary>

To block until the method returns pass this to [`ScriptBase.WaitFor`](/scripting/api/sansar.script/scriptbase#waitfor-func-2) in a coroutine.

</details>

</div>

### Play

<div class="api-card" id="play-noargs">
<span id="M:Sansar.Simulation.Animation.Play"></span>
<span id="M:Sansar.Simulation.Animation.Play()"></span>

```csharp signature
public void Play()
```

Plays the animation. It will become the active animation for this object, and resume playing if it is paused.

<details class="api-remarks"><summary>Remarks</summary>

If the animation has PlaybackMode.PlayOnce and has finished playing, this will have no effect, the animation will have to be reset with Reset() first. To block until the method returns pass this to [`ScriptBase.WaitFor`](/scripting/api/sansar.script/scriptbase#waitfor-func-2) in a coroutine.

</details>

</div>

<div class="api-card" id="play-operationcomplete">
<span id="M:Sansar.Simulation.Animation.Play(Sansar.Script.ScriptBase.OperationComplete)"></span>
<div class="api-badges"><span class="api-badge api-deprecated">Deprecated</span></div>

```csharp signature
[System.Obsolete("Deprecated. Use the Action<> overload", false)]
public ulong Play(Sansar.Script.ScriptBase.OperationComplete handler)
```

Plays the animation, without changing the current animation frame.

| Parameter | Type | Description |
|---|---|---|
| `handler` | [Sansar.Script.ScriptBase.OperationComplete](/scripting/api/sansar.script/scriptbase.operationcomplete) | Handler to be called when the event completes. |

**Returns:** [ulong](https://learn.microsoft.com/dotnet/api/system.uint64) — Returns an internal event id.

<details class="api-remarks"><summary>Remarks</summary>

If the animation has PlaybackMode.PlayOnce and has finished playing, this will have no effect, the animation will have to be reset with Reset() first. To block until the method returns pass this to [`ScriptBase.WaitFor`](/scripting/api/sansar.script/scriptbase#waitfor-func-2) in a coroutine.

</details>

</div>

<div class="api-card" id="play-animationparameters">
<span id="M:Sansar.Simulation.Animation.Play(Sansar.Simulation.AnimationParameters)"></span>

```csharp signature
public void Play(AnimationParameters parameters)
```

Plays the animation and applies the provided parameters.

| Parameter | Type | Description |
|---|---|---|
| `parameters` | [AnimationParameters](/scripting/api/sansar.simulation/animationparameters) | Animation parameters to apply. |

<details class="api-remarks"><summary>Remarks</summary>

To block until the method returns pass this to [`ScriptBase.WaitFor`](/scripting/api/sansar.script/scriptbase#waitfor-func-2) in a coroutine.

</details>

</div>

<div class="api-card" id="play-action">
<span id="M:Sansar.Simulation.Animation.Play(System.Action{Sansar.Script.OperationCompleteEvent})"></span>

```csharp signature
public void Play(Action<Sansar.Script.OperationCompleteEvent> handler)
```

Plays the animation. It will become the active animation for this object, and resume playing if it is paused.

| Parameter | Type | Description |
|---|---|---|
| `handler` | [Action&lt;Sansar.Script.OperationCompleteEvent&gt;](https://learn.microsoft.com/dotnet/api/system.action-1) | Handler to be called when the event completes. |

<details class="api-remarks"><summary>Remarks</summary>

If the animation has PlaybackMode.PlayOnce and has finished playing, this will have no effect, the animation will have to be reset with Reset() first. To block until the method returns pass this to [`ScriptBase.WaitFor`](/scripting/api/sansar.script/scriptbase#waitfor-func-2) in a coroutine.

</details>

</div>

<div class="api-card" id="play-animationparameters-operationcomplete">
<span id="M:Sansar.Simulation.Animation.Play(Sansar.Simulation.AnimationParameters,Sansar.Script.ScriptBase.OperationComplete)"></span>
<div class="api-badges"><span class="api-badge api-deprecated">Deprecated</span></div>

```csharp signature
[System.Obsolete("Deprecated. Use the Action<> overload", false)]
public ulong Play(
    AnimationParameters parameters,
    Sansar.Script.ScriptBase.OperationComplete handler
)
```

Plays the animation and applies the provided parameters.

| Parameter | Type | Description |
|---|---|---|
| `parameters` | [AnimationParameters](/scripting/api/sansar.simulation/animationparameters) | Animation parameters to apply. |
| `handler` | [Sansar.Script.ScriptBase.OperationComplete](/scripting/api/sansar.script/scriptbase.operationcomplete) | Handler to be called when the event completes. |

**Returns:** [ulong](https://learn.microsoft.com/dotnet/api/system.uint64) — Returns an internal event id.

<details class="api-remarks"><summary>Remarks</summary>

To block until the method returns pass this to [`ScriptBase.WaitFor`](/scripting/api/sansar.script/scriptbase#waitfor-func-2) in a coroutine.

</details>

</div>

<div class="api-card" id="play-animationparameters-action">
<span id="M:Sansar.Simulation.Animation.Play(Sansar.Simulation.AnimationParameters,System.Action{Sansar.Script.OperationCompleteEvent})"></span>

```csharp signature
public void Play(
    AnimationParameters parameters,
    Action<Sansar.Script.OperationCompleteEvent> handler
)
```

Plays the animation and applies the provided parameters.

| Parameter | Type | Description |
|---|---|---|
| `parameters` | [AnimationParameters](/scripting/api/sansar.simulation/animationparameters) | Animation parameters to apply. |
| `handler` | [Action&lt;Sansar.Script.OperationCompleteEvent&gt;](https://learn.microsoft.com/dotnet/api/system.action-1) | Handler to be called when the event completes. |

<details class="api-remarks"><summary>Remarks</summary>

To block until the method returns pass this to [`ScriptBase.WaitFor`](/scripting/api/sansar.script/scriptbase#waitfor-func-2) in a coroutine.

</details>

</div>

### Reset

<div class="api-card" id="reset-noargs">
<span id="M:Sansar.Simulation.Animation.Reset"></span>
<span id="M:Sansar.Simulation.Animation.Reset()"></span>

```csharp signature
public void Reset()
```

Resets the animation. The animation is paused and reset to frame 0 (or the RangeStartFrame if clamping is enabled).

<details class="api-remarks"><summary>Remarks</summary>

To block until the method returns pass this to [`ScriptBase.WaitFor`](/scripting/api/sansar.script/scriptbase#waitfor-func-2) in a coroutine.

</details>

</div>

<div class="api-card" id="reset-operationcomplete">
<span id="M:Sansar.Simulation.Animation.Reset(Sansar.Script.ScriptBase.OperationComplete)"></span>
<div class="api-badges"><span class="api-badge api-deprecated">Deprecated</span></div>

```csharp signature
[System.Obsolete("Deprecated. Use the Action<> overload", false)]
public ulong Reset(Sansar.Script.ScriptBase.OperationComplete handler)
```

Resets the animation. The animation is paused and reset to frame 0 (or the RangeStartFrame if clamping is enabled).

| Parameter | Type | Description |
|---|---|---|
| `handler` | [Sansar.Script.ScriptBase.OperationComplete](/scripting/api/sansar.script/scriptbase.operationcomplete) | Handler to be called when the event completes. |

**Returns:** [ulong](https://learn.microsoft.com/dotnet/api/system.uint64) — Returns an internal event id.

<details class="api-remarks"><summary>Remarks</summary>

To block until the method returns pass this to [`ScriptBase.WaitFor`](/scripting/api/sansar.script/scriptbase#waitfor-func-2) in a coroutine.

</details>

</div>

<div class="api-card" id="reset-animationparameters">
<span id="M:Sansar.Simulation.Animation.Reset(Sansar.Simulation.AnimationParameters)"></span>

```csharp signature
public void Reset(AnimationParameters parameters)
```

Resets the animation and applies the provided parameters.

| Parameter | Type | Description |
|---|---|---|
| `parameters` | [AnimationParameters](/scripting/api/sansar.simulation/animationparameters) | Animation parameters to apply. |

<details class="api-remarks"><summary>Remarks</summary>

To block until the method returns pass this to [`ScriptBase.WaitFor`](/scripting/api/sansar.script/scriptbase#waitfor-func-2) in a coroutine.

</details>

</div>

<div class="api-card" id="reset-action">
<span id="M:Sansar.Simulation.Animation.Reset(System.Action{Sansar.Script.OperationCompleteEvent})"></span>

```csharp signature
public void Reset(
    Action<Sansar.Script.OperationCompleteEvent> handler
)
```

Resets the animation. The animation is paused and reset to frame 0 (or the RangeStartFrame if clamping is enabled).

| Parameter | Type | Description |
|---|---|---|
| `handler` | [Action&lt;Sansar.Script.OperationCompleteEvent&gt;](https://learn.microsoft.com/dotnet/api/system.action-1) | Handler to be called when the event completes. |

<details class="api-remarks"><summary>Remarks</summary>

To block until the method returns pass this to [`ScriptBase.WaitFor`](/scripting/api/sansar.script/scriptbase#waitfor-func-2) in a coroutine.

</details>

</div>

<div class="api-card" id="reset-animationparameters-operationcomplete">
<span id="M:Sansar.Simulation.Animation.Reset(Sansar.Simulation.AnimationParameters,Sansar.Script.ScriptBase.OperationComplete)"></span>
<div class="api-badges"><span class="api-badge api-deprecated">Deprecated</span></div>

```csharp signature
[System.Obsolete("Deprecated. Use the Action<> overload", false)]
public ulong Reset(
    AnimationParameters parameters,
    Sansar.Script.ScriptBase.OperationComplete handler
)
```

Resets the animation and applies the provided parameters.

| Parameter | Type | Description |
|---|---|---|
| `parameters` | [AnimationParameters](/scripting/api/sansar.simulation/animationparameters) | Animation parameters to apply. |
| `handler` | [Sansar.Script.ScriptBase.OperationComplete](/scripting/api/sansar.script/scriptbase.operationcomplete) | Handler to be called when the event completes. |

**Returns:** [ulong](https://learn.microsoft.com/dotnet/api/system.uint64) — Returns an internal event id.

<details class="api-remarks"><summary>Remarks</summary>

To block until the method returns pass this to [`ScriptBase.WaitFor`](/scripting/api/sansar.script/scriptbase#waitfor-func-2) in a coroutine.

</details>

</div>

<div class="api-card" id="reset-animationparameters-action">
<span id="M:Sansar.Simulation.Animation.Reset(Sansar.Simulation.AnimationParameters,System.Action{Sansar.Script.OperationCompleteEvent})"></span>

```csharp signature
public void Reset(
    AnimationParameters parameters,
    Action<Sansar.Script.OperationCompleteEvent> handler
)
```

Resets the animation and applies the provided parameters.

| Parameter | Type | Description |
|---|---|---|
| `parameters` | [AnimationParameters](/scripting/api/sansar.simulation/animationparameters) | Animation parameters to apply. |
| `handler` | [Action&lt;Sansar.Script.OperationCompleteEvent&gt;](https://learn.microsoft.com/dotnet/api/system.action-1) | Handler to be called when the event completes. |

<details class="api-remarks"><summary>Remarks</summary>

To block until the method returns pass this to [`ScriptBase.WaitFor`](/scripting/api/sansar.script/scriptbase#waitfor-func-2) in a coroutine.

</details>

</div>

### SetParameters

<div class="api-card" id="setparameters-animationparameters">
<span id="M:Sansar.Simulation.Animation.SetParameters(Sansar.Simulation.AnimationParameters)"></span>

```csharp signature
public void SetParameters(AnimationParameters parameters)
```

Sets the parameters for the animation. The parameters are applied immediately.

| Parameter | Type | Description |
|---|---|---|
| `parameters` | [AnimationParameters](/scripting/api/sansar.simulation/animationparameters) | Animation parameters to apply. |

<details class="api-remarks"><summary>Remarks</summary>

The range start frame will be clamped to the length of the animation, and the range end frame will be clamped between the range start frame and the end of the animation. To block until the method returns pass this to [`ScriptBase.WaitFor`](/scripting/api/sansar.script/scriptbase#waitfor-func-2) in a coroutine.

</details>

</div>

<div class="api-card" id="setparameters-animationparameters-operationcomplete">
<span id="M:Sansar.Simulation.Animation.SetParameters(Sansar.Simulation.AnimationParameters,Sansar.Script.ScriptBase.OperationComplete)"></span>
<div class="api-badges"><span class="api-badge api-deprecated">Deprecated</span></div>

```csharp signature
[System.Obsolete("Deprecated. Use the Action<> overload", false)]
public ulong SetParameters(
    AnimationParameters parameters,
    Sansar.Script.ScriptBase.OperationComplete handler
)
```

Sets the parameters for the animation. The parameters are applied immediately.

| Parameter | Type | Description |
|---|---|---|
| `parameters` | [AnimationParameters](/scripting/api/sansar.simulation/animationparameters) | Animation parameters to apply. |
| `handler` | [Sansar.Script.ScriptBase.OperationComplete](/scripting/api/sansar.script/scriptbase.operationcomplete) | Handler to be called when the event completes. |

**Returns:** [ulong](https://learn.microsoft.com/dotnet/api/system.uint64) — Returns an internal event id.

<details class="api-remarks"><summary>Remarks</summary>

The range start frame will be clamped to the length of the animation, and the range end frame will be clamped between the range start frame and the end of the animation. To block until the method returns pass this to [`ScriptBase.WaitFor`](/scripting/api/sansar.script/scriptbase#waitfor-func-2) in a coroutine.

</details>

</div>

<div class="api-card" id="setparameters-animationparameters-action">
<span id="M:Sansar.Simulation.Animation.SetParameters(Sansar.Simulation.AnimationParameters,System.Action{Sansar.Script.OperationCompleteEvent})"></span>

```csharp signature
public void SetParameters(
    AnimationParameters parameters,
    Action<Sansar.Script.OperationCompleteEvent> handler
)
```

Sets the parameters for the animation. The parameters are applied immediately.

| Parameter | Type | Description |
|---|---|---|
| `parameters` | [AnimationParameters](/scripting/api/sansar.simulation/animationparameters) | Animation parameters to apply. |
| `handler` | [Action&lt;Sansar.Script.OperationCompleteEvent&gt;](https://learn.microsoft.com/dotnet/api/system.action-1) | Handler to be called when the event completes. |

<details class="api-remarks"><summary>Remarks</summary>

The range start frame will be clamped to the length of the animation, and the range end frame will be clamped between the range start frame and the end of the animation. To block until the method returns pass this to [`ScriptBase.WaitFor`](/scripting/api/sansar.script/scriptbase#waitfor-func-2) in a coroutine.

</details>

</div>


## Used in examples

- [AnimationExample.cs](https://github.com/Wookey-Technologies/sansar-script-starter/blob/66af8b516b701088d043e4615acfcf5779356604/examples/official/AnimationExample.cs)
- [ScriptLibrary/Scene/Animation.cs](https://github.com/Wookey-Technologies/sansar-script-starter/blob/66af8b516b701088d043e4615acfcf5779356604/examples/official/ScriptLibrary/Scene/Animation.cs)
- [ScriptLibrary/Scene/Emote.cs](https://github.com/Wookey-Technologies/sansar-script-starter/blob/66af8b516b701088d043e4615acfcf5779356604/examples/official/ScriptLibrary/Scene/Emote.cs)

<p class="api-generated" data-pagefind-ignore>Generated from the Sansar 47.10.0 client ScriptApi snapshot.</p>