new Animator()
Animator component plays animations on a Rig. Handles animation playback, transitions, and timing.
- Source
Extends
Members
(readonly) properties
The entity that this component is attached to.
- Inherited From
- Source
Methods
addAnimation(animation) → {Animator}
Add an animation to the animator.
| Name | Type | Description |
|---|---|---|
animation | Animation | The animation to add. |
- Source
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.
| Name | Type | Description |
|---|---|---|
eventSource | Object | Event emitter with on(event, listener). |
eventMap | Object.<string, (string|function())> | Event-to-animation mapping. |
- Source
This animator (for chaining).
- Type:
- Animator
deserialize(props)
Populates the component properties from a data object. Override this method for custom property handling.
| Name | Type | Description |
|---|---|---|
props | object | The properties object (usually from JSON). |
- Inherited From
- Source
getAnimation(name) → {Animation|null}
Get an animation by name.
| Name | Type | Description |
|---|---|---|
name | string | Animation name. |
- Source
- Type:
- Animation |
null
isPlaying(name) → {boolean}
Check if currently playing a specific animation.
| Name | Type | Description |
|---|---|---|
name | string | Animation name. |
- Source
- Type:
- boolean
pause()
Pause the current animation.
- Source
play(name, restart)
Play an animation by name.
| Name | Type | Default | Description |
|---|---|---|---|
name | string | Animation name. | |
restart | boolean | false | Whether to restart if already playing this animation. |
- Source
resume()
Resume a paused animation.
- Source
stop()
Stop the current animation.
- Source
unbindGameplayEvents()
Remove all gameplay event bindings.
- Source
update(deltaTime)
Update the animator. Should be called each frame.
| Name | Type | Description |
|---|---|---|
deltaTime | number | Time since last frame in seconds. |
- Source