AnimationPlayer
Plays named clips and controls their time.
Use Play() to start, Pause() to resume later and Stop() to stop and reset. Calling Play() again for the same clip is not an explicit restart. Full keys include the library name except for the empty global library.
Play() schedules property application; Advance(0) applies the pose immediately. For preview without method events, use Seek(..., update: true, updateOnly: true). When AnimationTree controls the same targets, change tree state instead of playing concurrently.
Complete example and diagnostics
Declarations checked against C# SDK 1.0.0. Expand a name to see declarations and documentation.
Constructors1
AnimationPlayerConstructor
public AnimationPlayer();Properties16
AssignedAnimationProperty
public StringName AssignedAnimation { get; set; }The assigned name remains after stopping; reading it does not prove active playback. Setting it while stopped configures the clip at time 0 without starting; setting it during playback switches clips.
AutoplayProperty
public StringName Autoplay { get; set; }The key of the animation to play when the scene loads.
ClearCacheOnStopProperty
public bool ClearCacheOnStop { get; set; }If true, the animation track cache is cleared when the animation is stopped or the playback queue becomes empty. If false, the track cache is preserved, which can improve performance when animations are frequently started and stopped.
CurrentAnimationProperty
public StringName CurrentAnimation { get; set; }The key of the currently playing animation. If no animation is playing, the property's value is an empty string. Changing this value does not restart the animation. See AnimationPlayer.Play for more information on playing animations.
Note: While this property appears in the Inspector, it's not meant to be edited, and it's not saved in the scene. This property is mainly used to get the currently playing animation, and internally for animation playback tracks. For more information, see Animation.
CurrentAnimationLengthProperty
public double CurrentAnimationLength { get; }The length (in seconds) of the currently playing animation.
CurrentAnimationPositionProperty
public double CurrentAnimationPosition { get; }The current clip time in seconds. Reading without a current clip, such as immediately after Stop(), emits an error and returns 0; that is not a successful start-position check. Assign a clip through AssignedAnimation or start Play() first. Pause retains the current position.
MethodCallModeProperty
public AnimationPlayer.AnimationMethodCallMode MethodCallMode { get; set; }MovieQuitOnFinishProperty
public bool MovieQuitOnFinish { get; set; }If true and the engine is running in Movie Maker mode (see MovieWriter), exits the engine with EntityTree.Quit as soon as an animation is done playing in this AnimationPlayer. A message is printed when the engine quits for this reason.
Note: This obeys the same logic as the AnimationMixer.AnimationFinished signal, so it will not quit the engine if the animation is set to be looping.
PlaybackActiveProperty
public bool PlaybackActive { get; set; }PlaybackAutoCaptureProperty
public bool PlaybackAutoCapture { get; set; }If true, performs AnimationMixer.Capture before playback automatically. This means just AnimationPlayer.PlayWithCapture is executed with default arguments instead of AnimationPlayer.Play.
Note: Capture interpolation is only performed if the animation contains a capture track. See also Animation.UpdateMode.Capture.
PlaybackAutoCaptureDurationProperty
public double PlaybackAutoCaptureDuration { get; set; }See also AnimationPlayer.PlayWithCapture and AnimationMixer.Capture.
If AnimationPlayer.PlaybackAutoCaptureDuration is negative value, the duration is set to the interval between the current position and the first key.
PlaybackAutoCaptureEaseTypeProperty
public Tween.EaseType PlaybackAutoCaptureEaseType { get; set; }The ease type of the capture interpolation. See also Tween.EaseType.
PlaybackAutoCaptureTransitionTypeProperty
public Tween.TransitionType PlaybackAutoCaptureTransitionType { get; set; }The transition type of the capture interpolation. See also Tween.TransitionType.
PlaybackDefaultBlendTimeProperty
public double PlaybackDefaultBlendTime { get; set; }The default time in which to blend animations. Ranges from 0 to 4096 with 0.01 precision.
PlaybackProcessModeProperty
public AnimationPlayer.AnimationProcessCallback PlaybackProcessMode { get; set; }SpeedScaleProperty
public float SpeedScale { get; set; }The speed scaling ratio. For example, if this value is 1, then the animation plays at normal speed. If it's 0.5, then it plays at half speed. If it's 2, then it plays at double speed.
If set to a negative value, the animation is played in reverse. If set to 0, the animation will not advance.
Methods60
AnimationGetNextStringName
public StringName AnimationGetNext(StringName animationFrom);Returns the key of the animation which is queued to play after the animation_from animation.
| Name | Type | Default |
|---|---|---|
animationFrom | StringName | — |
StringNameAnimationSetNextvoid
public void AnimationSetNext(StringName animationFrom, StringName animationTo);Triggers the animation_to animation when the animation_from animation completes.
| Name | Type | Default |
|---|---|---|
animationFrom | StringName | — |
animationTo | StringName | — |
ClearQueuevoid
public void ClearQueue();Clears all queued, unplayed animations.
GetAssignedAnimationStringName
public StringName GetAssignedAnimation();StringNameGetAutoCaptureDurationdouble
public double GetAutoCaptureDuration();doubleGetAutoCaptureEaseTypeTween.EaseType
public Tween.EaseType GetAutoCaptureEaseType();Tween.EaseTypeGetAutoCaptureTransitionTypeTween.TransitionType
public Tween.TransitionType GetAutoCaptureTransitionType();Tween.TransitionTypeGetAutoplayStringName
public StringName GetAutoplay();StringNameGetBlendTimedouble
public double GetBlendTime(StringName animationFrom, StringName animationTo);Returns the blend time (in seconds) between two animations, referenced by their keys.
| Name | Type | Default |
|---|---|---|
animationFrom | StringName | — |
animationTo | StringName | — |
doubleGetCurrentAnimationStringName
public StringName GetCurrentAnimation();StringNameGetCurrentAnimationLengthdouble
public double GetCurrentAnimationLength();doubleGetCurrentAnimationPositiondouble
public double GetCurrentAnimationPosition();The current clip time in seconds. Reading without a current clip, such as immediately after Stop(), emits an error and returns 0; that is not a successful start-position check. Assign a clip through AssignedAnimation or start Play() first. Pause retains the current position.
doubleGetDefaultBlendTimedouble
public double GetDefaultBlendTime();doubleGetMethodCallModeAnimationPlayer.AnimationMethodCallMode · Deprecated
public AnimationPlayer.AnimationMethodCallMode GetMethodCallMode();Returns the call mode used for "Call Method" tracks.
AnimationPlayer.AnimationMethodCallModeGetPlayingSpeedfloat
public float GetPlayingSpeed();Returns the actual playing speed of current animation or 0 if not playing. This speed is the AnimationPlayer.SpeedScale property multiplied by custom_speed argument specified when calling the AnimationPlayer.Play method.
Returns a negative value if the current animation is playing backwards.
floatGetProcessCallbackAnimationPlayer.AnimationProcessCallback · Deprecated
public AnimationPlayer.AnimationProcessCallback GetProcessCallback();Returns the process notification in which to update animations.
AnimationPlayer.AnimationProcessCallbackGetQueueReckfell.Collections.Array<StringName>
public Reckfell.Collections.Array<StringName> GetQueue();Returns a list of the animation keys that are currently queued to play.
Reckfell.Collections.Array<StringName>GetRootEntityPath · Deprecated
public EntityPath GetRoot();Returns the node which node path references will travel from.
EntityPathGetSectionEndTimedouble
public double GetSectionEndTime();Returns the end time of the section currently being played.
doubleGetSectionStartTimedouble
public double GetSectionStartTime();Returns the start time of the section currently being played.
doubleGetSpeedScalefloat
public float GetSpeedScale();floatHasSectionbool
public bool HasSection();Returns true if an animation is currently playing with a section.
boolIsAnimationActivebool
public bool IsAnimationActive();Returns true if the an animation is currently active. An animation is active if it was played by calling AnimationPlayer.Play and was not finished yet, or was stopped by calling AnimationPlayer.Stop.
This can be used to check whether an animation is currently paused or stopped.
boolIsAutoCapturebool
public bool IsAutoCapture();boolIsClearCacheOnStopEnabledbool
public bool IsClearCacheOnStopEnabled();boolIsMovieQuitOnFinishEnabledbool
public bool IsMovieQuitOnFinishEnabled();boolIsPlayingbool
public bool IsPlaying();Reports playback state, not whether the pose is changing or speed is nonzero. It can return true at SpeedScale=0. After Pause() it is false even though the assigned clip and its position remain.
boolPausevoid
public void Pause();Pauses automatic playback while retaining time and pose. Play() without a name resumes the assigned clip. An explicit manual Advance() can still step it; code that owns manual timing must account for pause.
Playvoid
public void Play(StringName name = null, double customBlend = -1d, float customSpeed = 1f, bool fromEnd = false);Plays a full library key; an empty name continues the assigned clip. Replaying the same name is not a restart command. Use Stop() then Play() for an explicit restart. Properties update during processing; Advance(0) applies the starting pose immediately. SpeedScale also affects playback speed.
| Name | Type | Default |
|---|---|---|
name | StringName | null |
customBlend | double | -1d |
customSpeed | float | 1f |
fromEnd | bool | false |
PlayBackwardsvoid
public void PlayBackwards(StringName name = null, double customBlend = -1d);Plays the animation with key name in reverse.
This method is a shorthand for AnimationPlayer.Play with custom_speed = -1.0 and from_end = true, so see its description for more information.
Note: Continuous tracks, including value tracks with Animation.UpdateMode.Continuous, are simply interpolated on the reversed timeline, while value tracks with Animation.UpdateMode.Discrete apply a key only in the frame it is passed, so the value held between two keys can differ from forward playback.
| Name | Type | Default |
|---|---|---|
name | StringName | null |
customBlend | double | -1d |
PlaySectionvoid
public void PlaySection(StringName name = null, double startTime = -1d, double endTime = -1d, double customBlend = -1d, float customSpeed = 1f, bool fromEnd = false);Plays the animation with key name and the section starting from start_time and ending on end_time. See also AnimationPlayer.Play.
Setting start_time to a value outside the range of the animation means the start of the animation will be used instead, and setting end_time to a value outside the range of the animation means the end of the animation will be used instead. start_time cannot be equal to end_time.
| Name | Type | Default |
|---|---|---|
name | StringName | null |
startTime | double | -1d |
endTime | double | -1d |
customBlend | double | -1d |
customSpeed | float | 1f |
fromEnd | bool | false |
PlaySectionBackwardsvoid
public void PlaySectionBackwards(StringName name = null, double startTime = -1d, double endTime = -1d, double customBlend = -1d);Plays the animation with key name and the section starting from start_time and ending on end_time in reverse.
This method is a shorthand for AnimationPlayer.PlaySection with custom_speed = -1.0 and from_end = true, see its description for more information.
| Name | Type | Default |
|---|---|---|
name | StringName | null |
startTime | double | -1d |
endTime | double | -1d |
customBlend | double | -1d |
PlaySectionWithMarkersvoid
public void PlaySectionWithMarkers(StringName name = null, StringName startMarker = null, StringName endMarker = null, double customBlend = -1d, float customSpeed = 1f, bool fromEnd = false);Plays the animation with key name and the section starting from start_marker and ending on end_marker.
If the start marker is empty, the section starts from the beginning of the animation. If the end marker is empty, the section ends on the end of the animation. See also AnimationPlayer.Play.
| Name | Type | Default |
|---|---|---|
name | StringName | null |
startMarker | StringName | null |
endMarker | StringName | null |
customBlend | double | -1d |
customSpeed | float | 1f |
fromEnd | bool | false |
PlaySectionWithMarkersBackwardsvoid
public void PlaySectionWithMarkersBackwards(StringName name = null, StringName startMarker = null, StringName endMarker = null, double customBlend = -1d);Plays the animation with key name and the section starting from start_marker and ending on end_marker in reverse.
This method is a shorthand for AnimationPlayer.PlaySectionWithMarkers with custom_speed = -1.0 and from_end = true, see its description for more information.
| Name | Type | Default |
|---|---|---|
name | StringName | null |
startMarker | StringName | null |
endMarker | StringName | null |
customBlend | double | -1d |
PlayWithCapturevoid
public void PlayWithCapture(StringName name = null, double duration = -1d, double customBlend = -1d, float customSpeed = 1f, bool fromEnd = false, Tween.TransitionType transType = Tween.TransitionType.Linear, Tween.EaseType easeType = Tween.EaseType.In);See also AnimationMixer.Capture.
You can use this method to use more detailed options for capture than those performed by AnimationPlayer.PlaybackAutoCapture. When AnimationPlayer.PlaybackAutoCapture is false, this method is almost the same as the following:
capture(name, duration, trans_type, ease_type)
play(name, custom_blend, custom_speed, from_end)If name is blank, it specifies AnimationPlayer.AssignedAnimation.
If duration is a negative value, the duration is set to the interval between the current position and the first key, when from_end is true, uses the interval between the current position and the last key instead.
Note: The duration takes AnimationPlayer.SpeedScale into account, but custom_speed does not, because the capture cache is interpolated with the blend result and the result may contain multiple animations.
| Name | Type | Default |
|---|---|---|
name | StringName | null |
duration | double | -1d |
customBlend | double | -1d |
customSpeed | float | 1f |
fromEnd | bool | false |
transType | Tween.TransitionType | Tween.TransitionType.Linear |
easeType | Tween.EaseType | Tween.EaseType.In |
Queuevoid
public void Queue(StringName name);Queues an animation for playback once the current animation and all previously queued animations are done. Note: If a looped animation is currently playing, the queued animation will never play unless the looped animation is stopped somehow.
| Name | Type | Default |
|---|---|---|
name | StringName | — |
ResetSectionvoid
public void ResetSection();Resets the current section. Does nothing if a section has not been set.
Seek2 overloads
public void Seek(double seconds, bool update);A seek overload without updateOnly. With update=true it can invoke the nearest method key. For preview without those calls, use the three-argument Seek(seconds, update:true, updateOnly:true).
| Name | Type | Default |
|---|---|---|
seconds | double | — |
update | bool | — |
public void Seek(double seconds, bool update = false, bool updateOnly = false);Changes the current clip time. update=true applies the pose immediately; updateOnly=true suppresses method-track calls during that update. An ordinary external seek can invoke the nearest method key and does not play every skipped event. Seeking to the end is not normal clip completion.
| Name | Type | Default |
|---|---|---|
seconds | double | — |
update | bool | false |
updateOnly | bool | false |
SetAssignedAnimation2 overloads
public void SetAssignedAnimation(StringName animation);| Name | Type | Default |
|---|---|---|
animation | StringName | — |
public void SetAssignedAnimation(string animation);| Name | Type | Default |
|---|---|---|
animation | string | — |
SetAutoCapturevoid
public void SetAutoCapture(bool autoCapture);| Name | Type | Default |
|---|---|---|
autoCapture | bool | — |
SetAutoCaptureDurationvoid
public void SetAutoCaptureDuration(double autoCaptureDuration);| Name | Type | Default |
|---|---|---|
autoCaptureDuration | double | — |
SetAutoCaptureEaseTypevoid
public void SetAutoCaptureEaseType(Tween.EaseType autoCaptureEaseType);| Name | Type | Default |
|---|---|---|
autoCaptureEaseType | Tween.EaseType | — |
SetAutoCaptureTransitionTypevoid
public void SetAutoCaptureTransitionType(Tween.TransitionType autoCaptureTransitionType);| Name | Type | Default |
|---|---|---|
autoCaptureTransitionType | Tween.TransitionType | — |
SetAutoplay2 overloads
public void SetAutoplay(StringName name);| Name | Type | Default |
|---|---|---|
name | StringName | — |
public void SetAutoplay(string name);| Name | Type | Default |
|---|---|---|
name | string | — |
SetBlendTimevoid
public void SetBlendTime(StringName animationFrom, StringName animationTo, double sec);Specifies a blend time (in seconds) between two animations, referenced by their keys.
| Name | Type | Default |
|---|---|---|
animationFrom | StringName | — |
animationTo | StringName | — |
sec | double | — |
SetClearCacheOnStopEnabledvoid
public void SetClearCacheOnStopEnabled(bool enabled);| Name | Type | Default |
|---|---|---|
enabled | bool | — |
SetCurrentAnimation2 overloads
public void SetCurrentAnimation(StringName animation);| Name | Type | Default |
|---|---|---|
animation | StringName | — |
public void SetCurrentAnimation(string animation);| Name | Type | Default |
|---|---|---|
animation | string | — |
SetDefaultBlendTimevoid
public void SetDefaultBlendTime(double sec);| Name | Type | Default |
|---|---|---|
sec | double | — |
SetMethodCallModevoid · Deprecated
public void SetMethodCallMode(AnimationPlayer.AnimationMethodCallMode mode);Sets the call mode used for "Call Method" tracks.
| Name | Type | Default |
|---|---|---|
mode | AnimationPlayer.AnimationMethodCallMode | — |
SetMovieQuitOnFinishEnabledvoid
public void SetMovieQuitOnFinishEnabled(bool enabled);| Name | Type | Default |
|---|---|---|
enabled | bool | — |
SetProcessCallbackvoid · Deprecated
public void SetProcessCallback(AnimationPlayer.AnimationProcessCallback mode);Sets the process notification in which to update animations.
| Name | Type | Default |
|---|---|---|
mode | AnimationPlayer.AnimationProcessCallback | — |
SetRootvoid · Deprecated
public void SetRoot(EntityPath path);Sets the node which node path references will travel from.
| Name | Type | Default |
|---|---|---|
path | EntityPath | — |
SetSectionvoid
public void SetSection(double startTime = -1d, double endTime = -1d);Changes the start and end times of the section being played. The current playback position will be clamped within the new section. See also AnimationPlayer.PlaySection.
| Name | Type | Default |
|---|---|---|
startTime | double | -1d |
endTime | double | -1d |
SetSectionWithMarkersvoid
public void SetSectionWithMarkers(StringName startMarker = null, StringName endMarker = null);Changes the start and end markers of the section being played. The current playback position will be clamped within the new section. See also AnimationPlayer.PlaySectionWithMarkers.
If the argument is empty, the section uses the beginning or end of the animation. If both are empty, it means that the section is not set.
| Name | Type | Default |
|---|---|---|
startMarker | StringName | null |
endMarker | StringName | null |
SetSpeedScalevoid
public void SetSpeedScale(float speed);| Name | Type | Default |
|---|---|---|
speed | float | — |
Stopvoid
public void Stop(bool keepState = false);Stops playback, clears the queue and resets time to the current section start. By default it applies that initial pose; keepState=true preserves applied values. It does not play RESET or emit AnimationFinished. The current position is unavailable until a clip is assigned or started again.
| Name | Type | Default |
|---|---|---|
keepState | bool | false |
Signals and events2
AnimationChangedEvent
public event AnimationPlayer.AnimationChangedEventHandler AnimationChanged;Emitted when a queued animation plays after the previous animation finished. See also AnimationPlayer.Queue.
Note: The signal is not emitted when the animation is changed via AnimationPlayer.Play or by an AnimationTree.
| Name | Type | Default |
|---|---|---|
oldName | StringName | — |
newName | StringName | — |
CurrentAnimationChangedEvent
public event AnimationPlayer.CurrentAnimationChangedEventHandler CurrentAnimationChanged;Emitted when AnimationPlayer.CurrentAnimation changes.
| Name | Type | Default |
|---|---|---|
animName | StringName | — |
AnimationPlayer.AnimationMethodCallMode
| Value | Description |
|---|---|
Deferred = 0 | |
Immediate = 1 |
AnimationPlayer.AnimationProcessCallback
| Value | Description |
|---|---|
Idle = 1 | |
Manual = 2 | |
Physics = 0 |