Skip to content

Get Sansar

Script API

AnimationComponent

Where: Client
More page actions

For the complete documentation index, see llms.txt. This page is also available as Markdown.

The AnimationComponent handles interactions with animations.

public class AnimationComponent : Sansar.Script.InstanceInterface

Remarks

Animated objects should be manipulated through this interface.

Members at a glance

KindMembers
FieldsComponentType
PropertiesComponentId · DefaultAnimation · Name
MethodsEnqueueEvent · GetAnimation · GetAnimations · GetEventId · GetVectorAnimationVariable · HasEvent · SetPosition · Subscribe · ToString

Fields

ComponentType

public static readonly ComponentType ComponentType

The 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

Added in 33.2.0
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.

ParameterTypeDescription
internalIdintThe id of the animation event, may be looked up by name from AnimationComponent.GetEventId
Remarks

Ids can be retrieved with AnimationComponent.GetEventId.

Deprecated
[System.Obsolete("Deprecated. Use the Action<> overload", false)] public ulong EnqueueEvent(     int internalId,     Sansar.Script.ScriptBase.OperationComplete handler )

Enqueues an event for this component.

ParameterTypeDescription
internalIdintThe id of the animation event, may be looked up by name from AnimationComponent.GetEventId
handlerSansar.Script.ScriptBase.OperationCompleteHandler 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.

ParameterTypeDescription
internalIdintThe id of the animation event, may be looked up by name from AnimationComponent.GetEventId
handlerAction<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.

ParameterTypeDescription
animationNamestringThe 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.

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

ParameterTypeDescription
variableNamestringThe 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.

ParameterTypeDescription
eventNamestringThe 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.

ParameterTypeDescription
positionSansar.VectorThe Mono.Simd.Vector4f position desired.
Remarks

To block until the method returns pass this to ScriptBase.WaitFor in a coroutine.

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

ParameterTypeDescription
positionSansar.VectorThe Mono.Simd.Vector4f position desired.
handlerSansar.Script.ScriptBase.OperationCompleteHandler 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.

ParameterTypeDescription
positionSansar.VectorThe Mono.Simd.Vector4f position desired.
handlerAction<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

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

ParameterTypeDescription
BehaviorNamestringThe behavior name of the Animation. This name will match the subscribed event.
callbackAnimationComponent.SubscriptionHandlerCallback which is executed when the event completes.
persistentboolOptional, set to false to unsubscribe after one event.
public Sansar.Script.IEventSubscription Subscribe(     string BehaviorName,     Action<AnimationData> callback,     bool persistent )

Subscribes to Animation Events.

ParameterTypeDescription
BehaviorNamestringThe behavior name of the Animation. This name will match the subscribed event.
callbackAction<AnimationData>Callback which is executed when the event completes.
persistentboolOptional, 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.