Animator

new Animator()

Animator component plays animations on a Rig. Handles animation playback, transitions, and timing.

Extends

Members

(readonly) properties

The entity that this component is attached to.

Inherited From

Methods

addAnimation(animation) → {Animator}

Add an animation to the animator.

Parameters:
NameTypeDescription
animationAnimation

The animation to add.

Returns:

This animator (for chaining).

Type: 
Animator

bindGameplayEvents(eventSource, eventMap) → {Animator}

Bind gameplay events to animation names. The event source must expose on(eventName, listener), returning an unsubscribe function (or provide off(eventName, listener)). Mapping values may be animation names or functions that return an animation name for the event payload. Existing bindings are replaced when this method is called again.

Parameters:
NameTypeDescription
eventSourceObject

Event emitter with on(event, listener).

eventMapObject.<string, (string|function())>

Event-to-animation mapping.

Returns:

This animator (for chaining).

Type: 
Animator

deserialize(props)

Populates the component properties from a data object. Override this method for custom property handling.

Parameters:
NameTypeDescription
propsobject

The properties object (usually from JSON).

Inherited From

getAnimation(name) → {Animation|null}

Get an animation by name.

Parameters:
NameTypeDescription
namestring

Animation name.

Returns:
Type: 
Animation | null

isPlaying(name) → {boolean}

Check if currently playing a specific animation.

Parameters:
NameTypeDescription
namestring

Animation name.

Returns:
Type: 
boolean

pause()

Pause the current animation.

play(name, restart)

Play an animation by name.

Parameters:
NameTypeDefaultDescription
namestring

Animation name.

restartbooleanfalse

Whether to restart if already playing this animation.

resume()

Resume a paused animation.

stop()

Stop the current animation.

unbindGameplayEvents()

Remove all gameplay event bindings.

update(deltaTime)

Update the animator. Should be called each frame.

Parameters:
NameTypeDescription
deltaTimenumber

Time since last frame in seconds.