# CharacterComponent

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>
<span class="api-badge api-since">Added in 39.1.0</span>
</div>

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

The CharacterComponent handles character specific operations like playing CharacterAnimations.

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

## Remarks

Allows for doing operations specific to characters using the Sansar skeleton types

## Members at a glance

| Kind | Members |
|---|---|
| **Fields** | [ComponentType](#componenttype) |
| **Properties** | [ComponentId](#componentid) · [UsingFemaleSkeleton](#usingfemaleskeleton) · [UsingMaleSkeleton](#usingmaleskeleton) |
| **Methods** | [PlayAnimation](#playanimation) · [StopAnimations](#stopanimations) · [ToString](#tostring) |

## Fields

### ComponentType

<div class="api-card">
<span id="F:Sansar.Simulation.CharacterComponent.ComponentType"></span>
<div class="api-badges"><span class="api-badge api-since">Added in 39.1.0</span></div>

```csharp signature
public static readonly ComponentType ComponentType
```

The [`CharacterComponent.ComponentType`](/scripting/api/sansar.simulation/charactercomponent#componenttype) of this component

</div>


## Properties

### ComponentId

<div class="api-card">
<span id="P:Sansar.Simulation.CharacterComponent.ComponentId"></span>
<div class="api-badges"><span class="api-badge api-since">Added in 39.1.0</span></div>

```csharp signature
public Sansar.Script.ComponentId ComponentId { get; }
```

Retrieves the component id for this CharacterComponent.

**Value:** [Sansar.Script.ComponentId](/scripting/api/sansar.script/componentid) — The id.

</div>

### UsingFemaleSkeleton

<div class="api-card">
<span id="P:Sansar.Simulation.CharacterComponent.UsingFemaleSkeleton"></span>
<div class="api-badges"><span class="api-badge api-since">Added in 39.1.0</span></div>

```csharp signature
public bool UsingFemaleSkeleton { get; }
```

Retrieves whether or not the avatar is using the female skeleton for this CharacterComponent.

**Value:** [bool](https://learn.microsoft.com/dotnet/api/system.boolean) — Whether or not the avatar is using the female skeleton

</div>

### UsingMaleSkeleton

<div class="api-card">
<span id="P:Sansar.Simulation.CharacterComponent.UsingMaleSkeleton"></span>
<div class="api-badges"><span class="api-badge api-since">Added in 39.1.0</span></div>

```csharp signature
public bool UsingMaleSkeleton { get; }
```

Retrieves whether or not the avatar is using the male skeleton for this CharacterComponent.

**Value:** [bool](https://learn.microsoft.com/dotnet/api/system.boolean) — Whether or not the avatar is using the male skeleton

</div>


## Methods

### PlayAnimation

<div class="api-card" id="playanimation-characteranimation-animationplaybackmode-animationbonesubset">
<span id="M:Sansar.Simulation.CharacterComponent.PlayAnimation(Sansar.Simulation.CharacterAnimation,Sansar.Simulation.AnimationPlaybackMode,Sansar.Simulation.AnimationBoneSubset)"></span>
<div class="api-badges"><span class="api-badge api-since">Added in 39.1.0</span></div>

```csharp signature
public void PlayAnimation(
    CharacterAnimation animation,
    AnimationPlaybackMode playbackMode,
    AnimationBoneSubset skeletonSubset
)
```

Plays an animation in server time synchronously for this CharacterComponent. If you want multiple agent&#39;s to play an animation together, use this function

| Parameter | Type | Description |
|---|---|---|
| `animation` | [CharacterAnimation](/scripting/api/sansar.simulation/characteranimation) | The animation to play on the agent. |
| `playbackMode` | [AnimationPlaybackMode](/scripting/api/sansar.simulation/animationplaybackmode) | How to play the animation. Only PlayOnce and Loop supported. |
| `skeletonSubset` | [AnimationBoneSubset](/scripting/api/sansar.simulation/animationbonesubset) | Which subset of the skeleton to play the animation on. |

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

This asynchronous method queues the write then returns.

</details>

</div>

<div class="api-card" id="playanimation-characteranimation-animationplaybackmode-animationbonesubset-action">
<span id="M:Sansar.Simulation.CharacterComponent.PlayAnimation(Sansar.Simulation.CharacterAnimation,Sansar.Simulation.AnimationPlaybackMode,Sansar.Simulation.AnimationBoneSubset,System.Action{Sansar.Script.OperationCompleteEvent})"></span>
<div class="api-badges"><span class="api-badge api-since">Added in 39.1.0</span></div>

```csharp signature
public void PlayAnimation(
    CharacterAnimation animation,
    AnimationPlaybackMode playbackMode,
    AnimationBoneSubset skeletonSubset,
    Action<Sansar.Script.OperationCompleteEvent> handler
)
```

Plays an animation in server time synchronously for this CharacterComponent. If you want multiple agent&#39;s to play an animation together, use this function

| Parameter | Type | Description |
|---|---|---|
| `animation` | [CharacterAnimation](/scripting/api/sansar.simulation/characteranimation) | The animation to play on the agent. |
| `playbackMode` | [AnimationPlaybackMode](/scripting/api/sansar.simulation/animationplaybackmode) | How to play the animation. Only PlayOnce and Loop supported. |
| `skeletonSubset` | [AnimationBoneSubset](/scripting/api/sansar.simulation/animationbonesubset) | Which subset of the skeleton to play the animation on. |
| `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>

This asynchronous method queues the write then returns.

</details>

</div>

<div class="api-card" id="playanimation-characteranimation-animationplaybackmode-animationbonesubset-single">
<span id="M:Sansar.Simulation.CharacterComponent.PlayAnimation(Sansar.Simulation.CharacterAnimation,Sansar.Simulation.AnimationPlaybackMode,Sansar.Simulation.AnimationBoneSubset,System.Single)"></span>
<div class="api-badges"><span class="api-badge api-since">Added in 39.1.0</span></div>

```csharp signature
public void PlayAnimation(
    CharacterAnimation animation,
    AnimationPlaybackMode playbackMode,
    AnimationBoneSubset skeletonSubset,
    float playbackSpeed
)
```

Plays an animation in server time synchronously for this CharacterComponent. If you want multiple agent&#39;s to play an animation together, use this function

| Parameter | Type | Description |
|---|---|---|
| `animation` | [CharacterAnimation](/scripting/api/sansar.simulation/characteranimation) | The animation to play on the agent. |
| `playbackMode` | [AnimationPlaybackMode](/scripting/api/sansar.simulation/animationplaybackmode) | How to play the animation. Only PlayOnce and Loop supported. |
| `skeletonSubset` | [AnimationBoneSubset](/scripting/api/sansar.simulation/animationbonesubset) | Which subset of the skeleton to play the animation on. |
| `playbackSpeed` | [float](https://learn.microsoft.com/dotnet/api/system.single) | Animation playback speed. Must be betweeen 0.1 and 10. |

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

This asynchronous method queues the write then returns.

</details>

</div>

<div class="api-card" id="playanimation-characteranimation-animationplaybackmode-animationbonesubset-single-action">
<span id="M:Sansar.Simulation.CharacterComponent.PlayAnimation(Sansar.Simulation.CharacterAnimation,Sansar.Simulation.AnimationPlaybackMode,Sansar.Simulation.AnimationBoneSubset,System.Single,System.Action{Sansar.Script.OperationCompleteEvent})"></span>
<div class="api-badges"><span class="api-badge api-since">Added in 39.1.0</span></div>

```csharp signature
public void PlayAnimation(
    CharacterAnimation animation,
    AnimationPlaybackMode playbackMode,
    AnimationBoneSubset skeletonSubset,
    float playbackSpeed,
    Action<Sansar.Script.OperationCompleteEvent> handler
)
```

Plays an animation in server time synchronously for this CharacterComponent. If you want multiple agent&#39;s to play an animation together, use this function

| Parameter | Type | Description |
|---|---|---|
| `animation` | [CharacterAnimation](/scripting/api/sansar.simulation/characteranimation) | The animation to play on the agent. |
| `playbackMode` | [AnimationPlaybackMode](/scripting/api/sansar.simulation/animationplaybackmode) | How to play the animation. Only PlayOnce and Loop supported. |
| `skeletonSubset` | [AnimationBoneSubset](/scripting/api/sansar.simulation/animationbonesubset) | Which subset of the skeleton to play the animation on. |
| `playbackSpeed` | [float](https://learn.microsoft.com/dotnet/api/system.single) | Animation playback speed. Must be betweeen 0.1 and 10. |
| `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>

This asynchronous method queues the write then returns.

</details>

</div>

### StopAnimations

<div class="api-card" id="stopanimations-noargs">
<span id="M:Sansar.Simulation.CharacterComponent.StopAnimations"></span>
<span id="M:Sansar.Simulation.CharacterComponent.StopAnimations()"></span>
<div class="api-badges"><span class="api-badge api-since">Added in 39.1.0</span></div>

```csharp signature
public void StopAnimations()
```

Stops all animations in server time synchronously for this CharacterComponent. If you want multiple agent&#39;s to stop animations together, use this function

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

This asynchronous method queues the write then returns.

</details>

</div>

<div class="api-card" id="stopanimations-animationbonesubset">
<span id="M:Sansar.Simulation.CharacterComponent.StopAnimations(Sansar.Simulation.AnimationBoneSubset)"></span>
<div class="api-badges"><span class="api-badge api-since">Added in 39.1.0</span></div>

```csharp signature
public void StopAnimations(AnimationBoneSubset skeletonSubset)
```

Stops all animations in server time synchronously for this CharacterComponent. If you want multiple agent&#39;s to stop animations together, use this function

| Parameter | Type | Description |
|---|---|---|
| `skeletonSubset` | [AnimationBoneSubset](/scripting/api/sansar.simulation/animationbonesubset) | All Animations for this skeleton subset will be stopped. |

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

This asynchronous method queues the write then returns.

</details>

</div>

<div class="api-card" id="stopanimations-action">
<span id="M:Sansar.Simulation.CharacterComponent.StopAnimations(System.Action{Sansar.Script.OperationCompleteEvent})"></span>
<div class="api-badges"><span class="api-badge api-since">Added in 39.1.0</span></div>

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

Stops all animations in server time synchronously for this CharacterComponent. If you want multiple agent&#39;s to stop animations together, use this function

| 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>

This asynchronous method queues the write then returns.

</details>

</div>

<div class="api-card" id="stopanimations-animationbonesubset-action">
<span id="M:Sansar.Simulation.CharacterComponent.StopAnimations(Sansar.Simulation.AnimationBoneSubset,System.Action{Sansar.Script.OperationCompleteEvent})"></span>
<div class="api-badges"><span class="api-badge api-since">Added in 39.1.0</span></div>

```csharp signature
public void StopAnimations(
    AnimationBoneSubset skeletonSubset,
    Action<Sansar.Script.OperationCompleteEvent> handler
)
```

Stops all animations in server time synchronously for this CharacterComponent. If you want multiple agent&#39;s to stop animations together, use this function

| Parameter | Type | Description |
|---|---|---|
| `skeletonSubset` | [AnimationBoneSubset](/scripting/api/sansar.simulation/animationbonesubset) | All Animations for this skeleton subset will be stopped. |
| `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>

This asynchronous method queues the write then returns.

</details>

</div>

### ToString

<div class="api-card">
<span id="M:Sansar.Simulation.CharacterComponent.ToString"></span>
<span id="M:Sansar.Simulation.CharacterComponent.ToString()"></span>
<div class="api-badges"><span class="api-badge api-since">Added in 39.1.0</span></div>

```csharp signature
public override string ToString()
```

A string representation of this object.

**Returns:** [string](https://learn.microsoft.com/dotnet/api/system.string) — A string representation of this object.

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

The format of this string may change between releases.

</details>

</div>


## Used in examples

- [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>