Class
Animator
Responsible for the playback and replication of Animations.
Animator is the main class responsible for the playback and replication of
Animations. All replication of playing
AnimationTracks is handled through the Animator
instance.
See Animation in Roblox to learn how to create and add pre-built or custom animations to your game.
Properties 2#
EvaluationThrottledboolean | Indicates whether animation evaluation was throttled (skipped) this frame
for this Animator.SafeReadOnlyNotReplicated |
PreferLodEnabledboolean | Controls whether animation LOD throttling is allowed for this
Animator. When set to false, animations always evaluate at full
fidelity.ReadSafe |
EvaluationThrottled: boolean#
ReadOnlyNotReplicatedSafe
A read-only property that indicates whether animation evaluation was
throttled (skipped) on this frame. When true, the Animator
reused the pose from the previous frame instead of evaluating fresh
animation data.
This property is useful when layering procedural animation on top of
Transform — if evaluation was
throttled, applying procedural offsets would fight the stale pose and
should be skipped:
PreferLodEnabled: boolean#
ReadSafe
When true (the default), the engine may reduce animation evaluation
frequency for remotely-simulated characters based on distance, screen
coverage, and frame budget. When set to false, LOD-based throttling is
disabled and this Animator always evaluates at full fidelity.
Setting this to false is useful for important NPCs or characters that
must always animate smoothly regardless of distance. However, disabling
LOD for many animators simultaneously can impact performance.
Note that this property only controls per-animator LOD throttling. The
workspace-level Workspace.ClientAnimatorThrottlingMode setting can
independently disable or enable throttling for all animators.
Methods 5#
| ApplyJointVelocities | Computes relative velocities between parts and applies them to
Motor6D.Part1. |
| GetPlayingAnimationTracks | Returns the list of currently active
AnimationTracks. |
| GetTrackByAnimationId | Returns an existing AnimationTrack on this Animator that
was loaded from an Animation with the given animation ID. Unlike
LoadAnimation(), this method does not
create a new AnimationTrack instance. |
| LoadAnimation | Loads an Animation onto an Animator, returning an
AnimationTrack. |
| StepAnimations | Increments the AnimationTrack.TimePosition of all playing
AnimationTracks that are loaded onto the
Animator, applying the offsets to the model associated with the
Animator. For use in the command bar or by plugins only.PluginSecurity security |
ApplyJointVelocities(motors: Variant): ()#
Given the current set of AnimationTracks playing
and their current times and play speeds, this method computes relative
velocities between the parts and applies them to Motor6D.Part1
(the part which Animator considers the "child" part). These relative
velocity calculations and assignments happen in the order provided.
This method doesn't apply velocities for a given joint if both of the joint's parts are currently part of the same assembly; for example, if they are still connected directly or indirectly by motors or welds.
Note that this method doesn't disable or remove the joints for you. You must disable or otherwise remove the rigid joints from the assembly before calling this method.
The given Motor6Ds are not required to be descendants of
the DataModel. Removing the joints from the DataModel
before calling this method is supported.
| Name | Type | Default | Description |
|---|---|---|---|
motors | Variant | An array of Motor6D instances to compute and apply velocities
for. |
Returns
()
GetPlayingAnimationTracks(): Array#
Returns the list of currently active
AnimationTracks on this Animator. This
includes tracks that are fading out and does not depend on
AnimationTrack.IsPlaying being true; as a result,
GetTrackByAnimationId() may be a
better option to get a specific AnimationTrack by its asset ID.
Fading tracks are automatically stopped and removed from this list once
their blend weight reaches zero.
Returns
Array— An array of currently activeAnimationTrackson thisAnimator, including tracks that are fading out.
GetTrackByAnimationId(animationId: ContentId): AnimationTrack?#
Returns an existing AnimationTrack on this Animator that
was loaded from an Animation with the given animation ID. Unlike
LoadAnimation(), this method does not
create a new AnimationTrack instance; it only looks up a track
that was previously loaded.
If multiple tracks have been loaded for the same animation ID, this method
returns the first match. If no matching track exists, it returns nil.
| Name | Type | Default | Description |
|---|---|---|---|
animationId | ContentId | The asset ID of the Animation whose loaded track should be
retrieved. |
Returns
AnimationTrack?— The firstAnimationTrackon thisAnimatorthat was loaded from the given animation ID, ornilif none has been loaded.
LoadAnimation(animation: Animation): AnimationTrack#
This method loads the given Animation onto this Animator,
returning a playable AnimationTrack. When called on an Animator
within models that the client has network ownership of, for example the
local player's character or from BasePart:SetNetworkOwner(), this
method also loads the animation for the server as well.
Note that the Animator must be in the Workspace before making a
call to LoadAnimation() or else it will be unable to retrieve the
AnimationClipProvider service and throw an error.
Warning#
Do not use LoadAnimation() in an attempt to retrieve an existing
track. Calling LoadAnimation() always creates a new
AnimationTrack instance which may impact game performance if
overused. Instead, use
GetTrackByAnimationId() when you
need to look up a track that was already loaded.
Loading an Animation on Client or Server#
In order for AnimationTracks to replicate
correctly, it's important to know when they should be loaded on the client
or on the server:
If an
Animatoris a descendant of aHumanoidorAnimationControllerin a player'sPlayer.Character, animations started on that player's client will be replicated to the server and other clients.If the
Animatoris not a descendant of a player character, its animations must be loaded and started on the server to replicate.
The Animator object must be initially created on the server and
replicated to clients for animation replication to work at all. If an
Animator is created locally, then AnimationTracks
loaded with that Animator will not replicate.
Returns
AnimationTrack— A newAnimationTracklinked to the givenAnimation.
StepAnimations(deltaTime: float): ()#
PluginSecurity security
Increments the AnimationTrack.TimePosition of all playing
AnimationTracks that are loaded onto the
Animator, applying the offsets to the model associated with the
Animator. For use in the command bar or by plugins only.
The deltaTime parameter determines the number of seconds to increment on
the animation's progress. Typically this method will be called in a loop
to preview the length of an animation (see example).
Note that once animations have stopped playing, the model's joints will need to be manually reset to their original positions (see example).
Access#
This method requires Plugin-level security. It can only be called from the
Studio command bar or from a Plugin. Regular Script and
LocalScript instances cannot call this method.
| Name | Type | Default | Description |
|---|---|---|---|
deltaTime | float | The amount of time in seconds animation playback is to be incremented. by. |
Returns
()
Events 1#
| AnimationPlayed | Fires when the Animator starts playing an AnimationTrack. |
AnimationPlayed(animationTrack: AnimationTrack)#
Fires for all AnimationTrack:Play() calls on
AnimationTracks created and owned by the
Animator.
| Name | Type | Default | Description |
|---|---|---|---|
animationTrack | AnimationTrack | The AnimationTrack that began playing. |
Inherited members#
Inherited from Instance 58
Properties (10)
Archivable, archivable, Capabilities, IsInSandbox, Name, Parent, PredictionMode, RobloxLocked, Sandboxed, UniqueId
Methods (39)
AddTag, children, ClearAllChildren, Clone, clone, Destroy, destroy, FindFirstAncestor, FindFirstAncestorOfClass, FindFirstAncestorWhichIsA, FindFirstChild, findFirstChild, FindFirstChildOfClass, FindFirstChildWhichIsA, FindFirstDescendant, GetActor, GetAttribute, GetAttributeChangedSignal, GetAttributes, GetChildren, getChildren, GetDebugId, GetDescendants, GetFullName, GetStyled, GetStyledPropertyChangedSignal, GetTags, HasTag, IsAncestorOf, IsDescendantOf, isDescendantOf, IsPropertyModified, QueryDescendants, Remove, remove, RemoveTag, ResetPropertyToDefault, SetAttribute, WaitForChild