The AnimationComponent handles interactions with animations.
public class AnimationComponent : Sansar.Script.InstanceInterfaceRemarks
Animated objects should be manipulated through this interface.
Members at a glance
| Kind | Members |
|---|---|
| Fields | ComponentType |
| Properties | ComponentId · DefaultAnimation · Name |
| Methods | EnqueueEvent · GetAnimation · GetAnimations · GetEventId · GetVectorAnimationVariable · HasEvent · SetPosition · Subscribe · ToString |
Fields
ComponentType
public static readonly ComponentType ComponentTypeThe AnimationComponent.ComponentType of this component
Properties
ComponentId
public Sansar.Script.ComponentId ComponentId { get; }Retrieves the component id for this AnimationComponent.
Value: Sansar.Script.ComponentId — The id.
Remarks
This id will be unique among all components.
DefaultAnimation
public Animation DefaultAnimation { get; }Gets the default scriptable animation.
Value: Animation — An Animation object.
Name
public string Name { get; }This AnimationComponent name, as specified in the editor.
Methods
EnqueueEvent
public void EnqueueEvent(int internalId)Enqueues an event for this component.
| Parameter | Type | Description |
|---|---|---|
internalId | int | The id of the animation event, may be looked up by name from AnimationComponent.GetEventId |
Remarks
Ids can be retrieved with AnimationComponent.GetEventId.
[System.Obsolete("Deprecated. Use the Action<> overload", false)]
public ulong EnqueueEvent(
int internalId,
Sansar.Script.ScriptBase.OperationComplete handler
)Enqueues an event for this component.
| Parameter | Type | Description |
|---|---|---|
internalId | int | The id of the animation event, may be looked up by name from AnimationComponent.GetEventId |
handler | Sansar.Script.ScriptBase.OperationComplete | Handler to be called when the event completes. |
Returns: ulong — The internal event id for the completion event.
Remarks
Ids can be retrieved with AnimationComponent.GetEventId.
public void EnqueueEvent(
int internalId,
Action<Sansar.Script.OperationCompleteEvent> handler
)Enqueues an event for this component.
| Parameter | Type | Description |
|---|---|---|
internalId | int | The id of the animation event, may be looked up by name from AnimationComponent.GetEventId |
handler | Action<Sansar.Script.OperationCompleteEvent> | Handler to be called when the event completes. |
Remarks
Ids can be retrieved with AnimationComponent.GetEventId.
GetAnimation
public Animation GetAnimation(string animationName)Finds a scriptable animations by name.
| Parameter | Type | Description |
|---|---|---|
animationName | string | The name of the animation. |
Returns: Animation — An Animation, or null if no animation was found with the correct name.
GetAnimations
public IEnumerable<Animation> GetAnimations()Gets the scriptable animations for this object.
Returns: IEnumerable<Animation> — An IEnumarable collection of animation objects.
GetEventId
public int GetEventId(string eventName)Lookup the event id for the named event.
| Parameter | Type | Description |
|---|---|---|
eventName | string | The name of the event to query. |
Returns: int — The id of the named event or -1 if the name is not valid.
Remarks
This can be used to trigger animations with AnimationComponent.EnqueueEvent.
GetVectorAnimationVariable
public Sansar.Vector GetVectorAnimationVariable(string variableName)Get a Vector type variable from the animation by name
| Parameter | Type | Description |
|---|---|---|
variableName | string | The name of the animation variable |
Returns: Sansar.Vector — A Mono.Simd.Vector4f of the value of the named variable
Throws ArgumentException: Thrown when attempting to get a variable that doesn’t exist or is of the wrong type
Throws ArgumentNullException: If variableName is null
Remarks
Characters have an ‘LLCameraForward’ variable which can be queried with GetVectorAnimationVariable to determine the forward vector of the camera.
HasEvent
public bool HasEvent(string eventName)Check this component for the existence of the named event.
| Parameter | Type | Description |
|---|---|---|
eventName | string | The name of the event to query. |
Returns: bool — true if the event exits.
Remarks
Can be used to check if an event exists.
SetPosition
public void SetPosition(Sansar.Vector position)Asynchronously set the position for this object.
| Parameter | Type | Description |
|---|---|---|
position | Sansar.Vector | The Mono.Simd.Vector4f position desired. |
Remarks
To block until the method returns pass this to ScriptBase.WaitFor in a coroutine.
[System.Obsolete("Deprecated. Use the Action<> overload", false)]
public ulong SetPosition(
Sansar.Vector position,
Sansar.Script.ScriptBase.OperationComplete handler
)Asynchronously set the position for this object.
| Parameter | Type | Description |
|---|---|---|
position | Sansar.Vector | The Mono.Simd.Vector4f position desired. |
handler | Sansar.Script.ScriptBase.OperationComplete | Handler to be called when the event completes. |
Returns: ulong — Returns an internal event id.
Remarks
To block until the method returns pass this to ScriptBase.WaitFor in a coroutine.
public void SetPosition(
Sansar.Vector position,
Action<Sansar.Script.OperationCompleteEvent> handler
)Asynchronously set the position for this object.
| Parameter | Type | Description |
|---|---|---|
position | Sansar.Vector | The Mono.Simd.Vector4f position desired. |
handler | Action<Sansar.Script.OperationCompleteEvent> | Handler to be called when the event completes. |
Remarks
To block until the method returns pass this to ScriptBase.WaitFor in a coroutine.
Subscribe
[System.Obsolete("Use subscription callbacks of type Action<Sansar.Simulation.AnimationData>", true)]
public void Subscribe(
string BehaviorName,
AnimationComponent.SubscriptionHandler callback,
bool persistent
)Subscribes to Animation Events.
| Parameter | Type | Description |
|---|---|---|
BehaviorName | string | The behavior name of the Animation. This name will match the subscribed event. |
callback | AnimationComponent.SubscriptionHandler | Callback which is executed when the event completes. |
persistent | bool | Optional, set to false to unsubscribe after one event. |
public Sansar.Script.IEventSubscription Subscribe(
string BehaviorName,
Action<AnimationData> callback,
bool persistent
)Subscribes to Animation Events.
| Parameter | Type | Description |
|---|---|---|
BehaviorName | string | The behavior name of the Animation. This name will match the subscribed event. |
callback | Action<AnimationData> | Callback which is executed when the event completes. |
persistent | bool | Optional, set to false to unsubscribe after one event. |
Returns: Sansar.Script.IEventSubscription — An IEventSubscription that can be used to cancel the subscription.
ToString
public override string ToString()A string representation of this object.
Returns: string — A string representation of this object.
Remarks
The format of this string may change between releases.
Used in examples
Generated from the Sansar 47.10.0 client ScriptApi snapshot.