Class: AnimationComponent
Single-clip playback (no blending). AnimationSystem samples curves each tick and writes values through auto-dirty setters, so animated property changes propagate naturally. Curves can target descendants — see AnimationClip for path/component/property semantics.
Clips come from two places: clipAssets (ids of .anim clip assets — what the editor authors) and clips (inline AnimationClip data — handy from code). Names must be unique across both; GetClip / Play look in clips first.
Extends
Constructors
Constructor
ts
new AnimationComponent(): AnimationComponent;Returns
AnimationComponent
Inherited from
Properties
| Property | Modifier | Type | Default value | Inherited from |
|---|---|---|---|---|
clipAssets | public | string[] | undefined | - |
clips | public | AnimationClip[] | undefined | - |
defaultClip | public | string | undefined | - |
dirty | public | boolean | true | Component.dirty |
enabled | public | boolean | true | Component.enabled |
playOnLoad | public | boolean | undefined | - |
Methods
GetClip()
ts
GetClip(name): AnimationClip | undefined;Parameters
| Parameter | Type |
|---|---|
name | string |
Returns
AnimationClip | undefined
GetClips()
ts
GetClips(): AnimationClip[];Every clip this component can play — inline first, then clip assets.
Returns
GetState()
ts
GetState(name):
| AnimationState
| undefined;Lazy-creates on first ask. Useful for things like anim.GetState('walk').time = 0.5.
Parameters
| Parameter | Type |
|---|---|
name | string |
Returns
| AnimationState | undefined
IsPlaying()
ts
IsPlaying(clipName?): boolean;Parameters
| Parameter | Type |
|---|---|
clipName? | string |
Returns
boolean
OnFinished()
ts
OnFinished(cb): AnimationUnsubscribe;Parameters
| Parameter | Type |
|---|---|
cb | (s) => void |
Returns
OnFrameEvent()
ts
OnFrameEvent(name, cb): AnimationUnsubscribe;Fires once per pass over the named marker in AnimationClip.events.
Parameters
| Parameter | Type |
|---|---|
name | string |
cb | (payload) => void |
Returns
OnLoopComplete()
ts
OnLoopComplete(cb): AnimationUnsubscribe;Parameters
| Parameter | Type |
|---|---|
cb | (s) => void |
Returns
OnPause()
ts
OnPause(cb): AnimationUnsubscribe;Parameters
| Parameter | Type |
|---|---|
cb | (s) => void |
Returns
OnPlay()
ts
OnPlay(cb): AnimationUnsubscribe;Parameters
| Parameter | Type |
|---|---|
cb | (s) => void |
Returns
OnResume()
ts
OnResume(cb): AnimationUnsubscribe;Parameters
| Parameter | Type |
|---|---|
cb | (s) => void |
Returns
OnStop()
ts
OnStop(cb): AnimationUnsubscribe;Parameters
| Parameter | Type |
|---|---|
cb | (s) => void |
Returns
Pause()
ts
Pause(): void;Returns
void
Play()
ts
Play(clipName?, options?):
| AnimationState
| null;---------- Playback ---------- Stops the in-flight clip first. Returns null if the name doesn't resolve to a clip.
Parameters
| Parameter | Type |
|---|---|
clipName? | string |
options? | AnimationPlayOptions |
Returns
| AnimationState | null
PlayClip()
ts
PlayClip(clip, options?): AnimationState;Plays clip data this component doesn't list (an Animator state's clip asset). Its state is kept under the clip's name, and replaced when a different object arrives (a reload).
Parameters
| Parameter | Type |
|---|---|
clip | AnimationClip |
options? | AnimationPlayOptions |
Returns
Resume()
ts
Resume(): void;Returns
void
Stop()
ts
Stop(): void;Returns
void