reckfellENGINE

AnimationMixer

Base class for AnimationPlayer and AnimationTree.

On this page
class AnimationMixerReckfellSharpInherits Entity

Base class for AnimationPlayer and AnimationTree.

Base class for AnimationPlayer and AnimationTree to manage animation lists. It also has general properties and methods for playback and blending. After instantiating the playback information data within the extended class, the blending is processed by the AnimationMixer.

Declarations checked against C# SDK 1.0.0. Expand a name to see declarations and documentation.

Properties10

ActiveProperty
# Active
C#
public bool Active { get; set; }

If true, the AnimationMixer will be processing.

AudioMaxPolyphonyProperty
# AudioMaxPolyphony
C#
public int AudioMaxPolyphony { get; set; }

The number of possible simultaneous sounds for each of the assigned AudioStreamPlayers. For example, if this value is 32 and the animation has two audio tracks, the two AudioStreamPlayers assigned can play simultaneously up to 32 voices each.

CallbackModeDiscreteProperty
# CallbackModeDiscrete
C#
public AnimationMixer.AnimationCallbackModeDiscrete CallbackModeDiscrete { get; set; }

Ordinarily, tracks can be set to Animation.UpdateMode.Discrete to update infrequently, usually when using nearest interpolation. However, when blending with Animation.UpdateMode.Continuous several results are considered. The AnimationMixer.CallbackModeDiscrete specify it explicitly. See also AnimationMixer.AnimationCallbackModeDiscrete. To make the blended results look good, it is recommended to set this to AnimationMixer.AnimationCallbackModeDiscrete.ForceContinuous to update every frame during blending. Other values exist for compatibility and they are fine if there is no blending, but not so, may produce artifacts.

CallbackModeMethodProperty
# CallbackModeMethod
C#
public AnimationMixer.AnimationCallbackModeMethod CallbackModeMethod { get; set; }

Controls Method-track call timing. Deferred queues calls after animation processing; Immediate invokes during processing. Deferred results can appear after Advance(). Do not restructure the playing hierarchy in an Immediate callback.

CallbackModeProcessProperty
# CallbackModeProcess
C#
public AnimationMixer.AnimationCallbackModeProcess CallbackModeProcess { get; set; }

Selects physics-step, frame-based or manual processing. Manual requires the timing owner to call Advance(). A physics callback does not turn direct Position animation into collision-resolved movement.

DeterministicProperty
# Deterministic
C#
public bool Deterministic { get; set; }

If true, the blending uses the deterministic algorithm. The total weight is not normalized and the result is accumulated with an initial value (0 or a "RESET" animation if present). This means that if the total amount of blending is 0.0, the result is equal to the "RESET" animation. If the number of tracks between the blended animations is different, the animation with the missing track is treated as if it had the initial value. If false, The blend does not use the deterministic algorithm. The total weight is normalized and always 1.0. If the number of tracks between the blended animations is different, nothing is done about the animation that is missing a track. Note: In AnimationTree, the blending with AnimationNodeAdd2, AnimationNodeAdd3, AnimationNodeSub2 or the weight greater than 1.0 may produce unexpected results. For example, if AnimationNodeAdd2 blends two nodes with the amount 1.0, then total weight is 2.0 but it will be normalized to make the total amount 1.0 and the result will be equal to AnimationNodeBlend2 with the amount 0.5.

ResetOnSaveProperty
# ResetOnSave
C#
public bool ResetOnSave { get; set; }

This is used by the editor. If set to true, the scene will be saved with the effects of the reset animation (the animation with the key "RESET") applied as if it had been seeked to time 0, with the editor keeping the values that the scene had before saving. This makes it more convenient to preview and edit animations in the editor, as changes to the scene will not be saved as long as they are set in the reset animation.

RootEntityProperty
# RootEntity
C#
public EntityPath RootEntity { get; set; }

The node which node path references will travel from.

RootMotionLocalProperty
# RootMotionLocal
C#
public bool RootMotionLocal { get; set; }

If true, AnimationMixer.GetRootMotionPosition value is extracted as a local translation value before blending. In other words, it is treated like the translation is done after the rotation.

RootMotionTrackProperty
# RootMotionTrack
C#
public EntityPath RootMotionTrack { get; set; }

The path to the Animation track used for root motion. Paths must be valid scene-tree paths to a node, and must be specified starting from the parent node of the node that will reproduce the animation. The AnimationMixer.RootMotionTrack uses the same format as Animation.TrackSetPath, but note that a bone must be specified. If the track has type Animation.TrackType.Position3D, Animation.TrackType.Rotation3D, or Animation.TrackType.Scale3D the transformation will be canceled visually, and the animation will appear to stay in place. See also AnimationMixer.GetRootMotionPosition, AnimationMixer.GetRootMotionRotation, AnimationMixer.GetRootMotionScale, and RootMotionView.

Methods42

AddAnimationLibraryError
# AddAnimationLibrary
C#
public Error AddAnimationLibrary(StringName name, AnimationLibrary library);

Adds library to the animation player, under the key name. AnimationMixer has a global library by default with an empty string as key. For adding an animation to the global library:

Parameters
NameTypeDefault
nameStringName—
libraryAnimationLibrary—
Returns Error
Advancevoid
# Advance
C#
public void Advance(double delta);

Explicitly processes delta seconds of animation. Use CallbackModeProcess=Manual for custom timing, avoiding an extra automatic step. A zero step applies the current pose. In AnimationPlayer an explicit step can advance a paused but still assigned clip.

Parameters
NameTypeDefault
deltadouble—
Capturevoid
# Capture
C#
public void Capture(StringName name, double duration, Tween.TransitionType transType = Tween.TransitionType.Linear, Tween.EaseType easeType = Tween.EaseType.In);

If the animation track specified by name has an option Animation.UpdateMode.Capture, stores current values of the objects indicated by the track path as a cache. If there is already a captured cache, the old cache is discarded. After this it will interpolate with current animation blending result during the playback process for the time specified by duration, working like a crossfade. You can specify trans_type as the curve for the interpolation. For better results, it may be appropriate to specify Tween.TransitionType.Linear for cases where the first key of the track begins with a non-zero value or where the key value does not change, and Tween.TransitionType.Quad for cases where the key value changes linearly.

Parameters
NameTypeDefault
nameStringName—
durationdouble—
transTypeTween.TransitionTypeTween.TransitionType.Linear
easeTypeTween.EaseTypeTween.EaseType.In
ClearCachesvoid
# ClearCaches
C#
public void ClearCaches();

AnimationMixer caches animated nodes. It may not notice if a node disappears; AnimationMixer.ClearCaches forces it to update the cache again.

FindAnimationStringName
# FindAnimation
C#
public StringName FindAnimation(Animation animation);

Returns the key of animation or an empty StringName if not found.

Parameters
NameTypeDefault
animationAnimation—
Returns StringName
FindAnimationLibraryStringName
# FindAnimationLibrary
C#
public StringName FindAnimationLibrary(Animation animation);

Returns the key for the AnimationLibrary that contains animation or an empty StringName if not found.

Parameters
NameTypeDefault
animationAnimation—
Returns StringName
GetAnimationAnimation
# GetAnimation
C#
public Animation GetAnimation(StringName name);

Returns the Animation with the key name. If the animation does not exist, null is returned and an error is logged.

Parameters
NameTypeDefault
nameStringName—
Returns Animation
GetAnimationLibraryAnimationLibrary
# GetAnimationLibrary
C#
public AnimationLibrary GetAnimationLibrary(StringName name);

Returns the first AnimationLibrary with key name or null if not found. To get the AnimationMixer's global animation library, use get_animation_library("").

Parameters
NameTypeDefault
nameStringName—
Returns AnimationLibrary
GetAnimationLibraryListReckfell.Collections.Array<StringName>
# GetAnimationLibraryList
C#
public Reckfell.Collections.Array<StringName> GetAnimationLibraryList();

Returns the list of stored library keys.

Returns Reckfell.Collections.Array<StringName>
GetAnimationListstring[]
# GetAnimationList
C#
public string[] GetAnimationList();

Returns the list of stored animation keys.

Returns string[]
GetAudioMaxPolyphonyint
# GetAudioMaxPolyphony
C#
public int GetAudioMaxPolyphony();
Returns int
GetCallbackModeDiscreteAnimationMixer.AnimationCallbackModeDiscrete
# GetCallbackModeDiscrete
C#
public AnimationMixer.AnimationCallbackModeDiscrete GetCallbackModeDiscrete();
Returns AnimationMixer.AnimationCallbackModeDiscrete
GetCallbackModeMethodAnimationMixer.AnimationCallbackModeMethod
# GetCallbackModeMethod
C#
public AnimationMixer.AnimationCallbackModeMethod GetCallbackModeMethod();
Returns AnimationMixer.AnimationCallbackModeMethod
GetCallbackModeProcessAnimationMixer.AnimationCallbackModeProcess
# GetCallbackModeProcess
C#
public AnimationMixer.AnimationCallbackModeProcess GetCallbackModeProcess();
Returns AnimationMixer.AnimationCallbackModeProcess
GetRootEntityEntityPath
# GetRootEntity
C#
public EntityPath GetRootEntity();
Returns EntityPath
GetRootMotionPositionVector3
# GetRootMotionPosition
C#
public Vector3 GetRootMotionPosition();

Returns extracted root-motion displacement for the last processed step, not velocity or the body world position. For CharacterBody3D, transform to the intended coordinate frame, divide displacement by delta for Velocity, then use MoveAndSlide(). Do not apply the same displacement directly a second time.

Returns Vector3
GetRootMotionPositionAccumulatorVector3
# GetRootMotionPositionAccumulator
C#
public Vector3 GetRootMotionPositionAccumulator();

Retrieve the blended value of the position tracks with the AnimationMixer.RootMotionTrack as a Vector3 that can be used elsewhere. This is useful in cases where you want to respect the initial key values of the animation. For example, if an animation with only one key Vector3(0, 0, 0) is played in the previous frame and then an animation with only one key Vector3(1, 0, 1) is played in the next frame, the difference can be calculated as follows:

However, if the animation loops, an unintended discrete change may occur, so this is only useful for some simple use cases.

Returns Vector3
GetRootMotionRotationQuaternion
# GetRootMotionRotation
C#
public Quaternion GetRootMotionRotation();

Retrieve the motion delta of rotation with the AnimationMixer.RootMotionTrack as a Quaternion that can be used elsewhere. If AnimationMixer.RootMotionTrack is not a path to a track of type Animation.TrackType.Rotation3D, returns Quaternion(0, 0, 0, 1). See also AnimationMixer.RootMotionTrack and RootMotionView. The most basic example is applying rotation to CharacterBody3D:

Returns Quaternion
GetRootMotionRotationAccumulatorQuaternion
# GetRootMotionRotationAccumulator
C#
public Quaternion GetRootMotionRotationAccumulator();

Retrieve the blended value of the rotation tracks with the AnimationMixer.RootMotionTrack as a Quaternion that can be used elsewhere. This is necessary to apply the root motion position correctly, taking rotation into account. See also AnimationMixer.GetRootMotionPosition. Also, this is useful in cases where you want to respect the initial key values of the animation. For example, if an animation with only one key Quaternion(0, 0, 0, 1) is played in the previous frame and then an animation with only one key Quaternion(0, 0.707, 0, 0.707) is played in the next frame, the difference can be calculated as follows:

However, if the animation loops, an unintended discrete change may occur, so this is only useful for some simple use cases.

Returns Quaternion
GetRootMotionScaleVector3
# GetRootMotionScale
C#
public Vector3 GetRootMotionScale();

Retrieve the motion delta of scale with the AnimationMixer.RootMotionTrack as a Vector3 that can be used elsewhere. If AnimationMixer.RootMotionTrack is not a path to a track of type Animation.TrackType.Scale3D, returns Vector3(0, 0, 0). See also AnimationMixer.RootMotionTrack and RootMotionView. The most basic example is applying scale to CharacterBody3D:

Returns Vector3
GetRootMotionScaleAccumulatorVector3
# GetRootMotionScaleAccumulator
C#
public Vector3 GetRootMotionScaleAccumulator();

Retrieve the blended value of the scale tracks with the AnimationMixer.RootMotionTrack as a Vector3 that can be used elsewhere. For example, if an animation with only one key Vector3(1, 1, 1) is played in the previous frame and then an animation with only one key Vector3(2, 2, 2) is played in the next frame, the difference can be calculated as follows:

However, if the animation loops, an unintended discrete change may occur, so this is only useful for some simple use cases.

Returns Vector3
GetRootMotionTrackEntityPath
# GetRootMotionTrack
C#
public EntityPath GetRootMotionTrack();
Returns EntityPath
HasAnimationbool
# HasAnimation
C#
public bool HasAnimation(StringName name);

Returns true if the AnimationMixer stores an Animation with key name.

Parameters
NameTypeDefault
nameStringName—
Returns bool
HasAnimationLibrarybool
# HasAnimationLibrary
C#
public bool HasAnimationLibrary(StringName name);

Returns true if the AnimationMixer stores an AnimationLibrary with key name.

Parameters
NameTypeDefault
nameStringName—
Returns bool
IsActivebool
# IsActive
C#
public bool IsActive();
Returns bool
IsDeterministicbool
# IsDeterministic
C#
public bool IsDeterministic();
Returns bool
IsResetOnSaveEnabledbool
# IsResetOnSaveEnabled
C#
public bool IsResetOnSaveEnabled();
Returns bool
IsRootMotionLocalbool
# IsRootMotionLocal
C#
public bool IsRootMotionLocal();
Returns bool
RemoveAnimationLibraryvoid
# RemoveAnimationLibrary
C#
public void RemoveAnimationLibrary(StringName name);

Removes the AnimationLibrary associated with the key name.

Parameters
NameTypeDefault
nameStringName—
RenameAnimationLibraryvoid
# RenameAnimationLibrary
C#
public void RenameAnimationLibrary(StringName name, StringName newname);

Moves the AnimationLibrary associated with the key name to the key newname.

Parameters
NameTypeDefault
nameStringName—
newnameStringName—
SetActivevoid
# SetActive
C#
public void SetActive(bool active);
Parameters
NameTypeDefault
activebool—
SetAudioMaxPolyphonyvoid
# SetAudioMaxPolyphony
C#
public void SetAudioMaxPolyphony(int maxPolyphony);
Parameters
NameTypeDefault
maxPolyphonyint—
SetCallbackModeDiscretevoid
# SetCallbackModeDiscrete
C#
public void SetCallbackModeDiscrete(AnimationMixer.AnimationCallbackModeDiscrete mode);
Parameters
NameTypeDefault
modeAnimationMixer.AnimationCallbackModeDiscrete—
SetCallbackModeMethodvoid
# SetCallbackModeMethod
C#
public void SetCallbackModeMethod(AnimationMixer.AnimationCallbackModeMethod mode);
Parameters
NameTypeDefault
modeAnimationMixer.AnimationCallbackModeMethod—
SetCallbackModeProcessvoid
# SetCallbackModeProcess
C#
public void SetCallbackModeProcess(AnimationMixer.AnimationCallbackModeProcess mode);
Parameters
NameTypeDefault
modeAnimationMixer.AnimationCallbackModeProcess—
SetDeterministicvoid
# SetDeterministic
C#
public void SetDeterministic(bool deterministic);
Parameters
NameTypeDefault
deterministicbool—
SetResetOnSaveEnabledvoid
# SetResetOnSaveEnabled
C#
public void SetResetOnSaveEnabled(bool enabled);
Parameters
NameTypeDefault
enabledbool—
SetRootEntityvoid
# SetRootEntity
C#
public void SetRootEntity(EntityPath path);
Parameters
NameTypeDefault
pathEntityPath—
SetRootMotionLocalvoid
# SetRootMotionLocal
C#
public void SetRootMotionLocal(bool enabled);
Parameters
NameTypeDefault
enabledbool—
SetRootMotionTrackvoid
# SetRootMotionTrack
C#
public void SetRootMotionTrack(EntityPath path);
Parameters
NameTypeDefault
pathEntityPath—
_PostProcessKeyValue2 overloads
# _PostProcessKeyValue · 1/2
C#
public Variant _PostProcessKeyValue(Animation animation, int track, Variant value, ReckfellObject @object, int objectIdx);

A virtual function for processing after getting a key during playback.

Parameters
NameTypeDefault
animationAnimation—
trackint—
valueVariant—
objectReckfellObject—
objectIdxint—
Returns Variant
# _PostProcessKeyValue · 2/2
C#
public virtual Variant _PostProcessKeyValue(Animation animation, int track, Variant value, ulong objectId, int objectSubIdx);

A virtual function for processing after getting a key during playback.

Parameters
NameTypeDefault
animationAnimation—
trackint—
valueVariant—
objectIdulong—
objectSubIdxint—
Returns Variant

Signals and events7

AnimationFinishedEvent
# AnimationFinished
C#
public event AnimationMixer.AnimationFinishedEventHandler AnimationFinished;

Reports the normal completion of an individual nonlooping clip. Stop() and seeking to the end do not substitute for it. In AnimationTree, clip completion does not mean that the whole graph or gameplay action has finished. Account for cancellation and object deletion when awaiting it.

Handler parameters
NameTypeDefault
animNameStringName—
AnimationLibrariesUpdatedEvent
# AnimationLibrariesUpdated
C#
public event Action AnimationLibrariesUpdated;

Notifies when the animation libraries have changed.

AnimationListChangedEvent
# AnimationListChanged
C#
public event Action AnimationListChanged;

Notifies when an animation list is changed.

AnimationStartedEvent
# AnimationStarted
C#
public event AnimationMixer.AnimationStartedEventHandler AnimationStarted;

Notifies when an animation starts playing. Note: This signal is not emitted if an animation is looping.

Handler parameters
NameTypeDefault
animNameStringName—
CachesClearedEvent
# CachesCleared
C#
public event Action CachesCleared;

Notifies when the caches have been cleared, either automatically, or manually via AnimationMixer.ClearCaches.

MixerAppliedEvent
# MixerApplied
C#
public event Action MixerApplied;

Notifies when the blending result related have been applied to the target objects.

MixerUpdatedEvent
# MixerUpdated
C#
public event Action MixerUpdated;

Notifies when the property related process have been updated.

AnimationMixer.AnimationCallbackModeDiscrete

ValueDescription
Dominant = 0

An Animation.UpdateMode.Discrete track value takes precedence when blending Animation.UpdateMode.Continuous or Animation.UpdateMode.Capture track values and Animation.UpdateMode.Discrete track values.

ForceContinuous = 2

Always treat the Animation.UpdateMode.Discrete track value as Animation.UpdateMode.Continuous with Animation.InterpolationType.Nearest. This is the default behavior for AnimationTree. If a value track has un-interpolatable type key values, it is internally converted to use AnimationMixer.AnimationCallbackModeDiscrete.Recessive with Animation.UpdateMode.Discrete. Un-interpolatable type list:

Recessive = 1

An Animation.UpdateMode.Continuous or Animation.UpdateMode.Capture track value takes precedence when blending the Animation.UpdateMode.Continuous or Animation.UpdateMode.Capture track values and the Animation.UpdateMode.Discrete track values. This is the default behavior for AnimationPlayer.

AnimationMixer.AnimationCallbackModeMethod

ValueDescription
Deferred = 0

Batch method calls during the animation process, then do the calls after events are processed. This avoids bugs involving deleting nodes or modifying the AnimationPlayer while playing.

Immediate = 1

Make method calls immediately when reached in the animation.

AnimationMixer.AnimationCallbackModeProcess

ValueDescription
Idle = 1

Process animation during process frames (see Entity.NotificationInternalProcess).

Manual = 2

Do not process animation. Use AnimationMixer.Advance to process the animation manually.

Physics = 0

Process animation during physics frames (see Entity.NotificationInternalPhysicsProcess). This is especially useful when animating physics bodies.

Reckfell Engine documentationBack to top ↑
QUICK LINKSGetting startedEntity hierarchyC# & .NET 10Scenes and prefabs
Reckfell guides and full API K
reckfellENGINE
RECKFELL ACCOUNT

Sign in

Sign in to your Reckfell account.

One account for the entire Reckfell platform.