AnimationTrack
Controls the playback of an animation on an Animator.
Memory category | Animation |
---|
Member index 22
Description
Controls the playback of an animation on an Animator. This object cannot be created, instead it is returned by the Animator:LoadAnimation() method.
History 71
- 665 Add SetTargetInstance
- 665 Add GetTargetNames
- 665 Add GetTargetInstance
- 573 Change ReturnType of Stop from void to null
- 573 Change ReturnType of Play from void to null
- 573 Change ReturnType of AdjustWeight from void to null
- 573 Change ReturnType of AdjustSpeed from void to null
- 570 Change Tags of Stop from [] to [CustomLuaState]
- 570 Change Tags of Play from [] to [CustomLuaState]
- 570 Change Tags of AdjustWeight from [] to [CustomLuaState]
- 570 Change Tags of AdjustSpeed from [] to [CustomLuaState]
- 553 Change Default of WeightTarget from to
- 553 Change Default of WeightCurrent from to
- 553 Change Default of TimePosition from to
- 553 Change Default of Speed from to
- 553 Change Default of Priority from to
- 553 Change Default of Looped from to
- 553 Change Default of Length from to
- 553 Change Default of IsPlaying from to
- 553 Change Default of Animation from to
- 550 Add Ended
- 486 Change ThreadSafety of WeightTarget from ReadOnly to ReadSafe
- 486 Change ThreadSafety of WeightCurrent from ReadOnly to ReadSafe
- 486 Change ThreadSafety of TimePosition from ReadOnly to ReadSafe
- 486 Change ThreadSafety of Speed from ReadOnly to ReadSafe
- 486 Change ThreadSafety of Priority from ReadOnly to ReadSafe
- 486 Change ThreadSafety of Looped from ReadOnly to ReadSafe
- 486 Change ThreadSafety of Length from ReadOnly to ReadSafe
- 486 Change ThreadSafety of IsPlaying from ReadOnly to ReadSafe
- 486 Change ThreadSafety of Animation from ReadOnly to ReadSafe
- 462 Change ThreadSafety of Stopped from to Unsafe
- 462 Change ThreadSafety of KeyframeReached from to Unsafe
- 462 Change ThreadSafety of DidLoop from to Unsafe
- 462 Change ThreadSafety of Stop from to Unsafe
- 462 Change ThreadSafety of Play from to Unsafe
- 462 Change ThreadSafety of GetTimeOfKeyframe from to Unsafe
- 462 Change ThreadSafety of GetMarkerReachedSignal from to Unsafe
- 462 Change ThreadSafety of AdjustWeight from to Unsafe
- 462 Change ThreadSafety of AdjustSpeed from to Unsafe
- 462 Change ThreadSafety of WeightTarget from to ReadOnly
- 462 Change ThreadSafety of WeightCurrent from to ReadOnly
- 462 Change ThreadSafety of TimePosition from to ReadOnly
- 462 Change ThreadSafety of Speed from to ReadOnly
- 462 Change ThreadSafety of Priority from to ReadOnly
- 462 Change ThreadSafety of Looped from to ReadOnly
- 462 Change ThreadSafety of Length from to ReadOnly
- 462 Change ThreadSafety of IsPlaying from to ReadOnly
- 462 Change ThreadSafety of Animation from to ReadOnly
- 366 Add GetMarkerReachedSignal
- 329 Change ValueType of Animation from Object to Animation
- 299 Add WeightTarget
- 299 Add WeightCurrent
- 299 Add Speed
- 280 Add DidLoop
- 280 Add Looped
- 248 Change Tags of Stopped from [Deprecated] to []
- 206 Add GetTimeOfKeyframe
- 206 Add TimePosition
- 204 Add Animation
- 202 Add Priority
- 202 Add Length
- 202 Add IsPlaying
- 55 Change Tags of AnimationTrack from [preliminary, NotCreatable] to [NotCreatable]
- 48 Change Tags of Stopped from [] to [Deprecated]
- 47 Add Stopped
- 47 Add KeyframeReached
- 47 Add Stop
- 47 Add Play
- 47 Add AdjustWeight
- 47 Add AdjustSpeed
- 47 Add AnimationTrack
Members 22
AdjustSpeed
Parameters (1) | Default | |
---|---|---|
speed | float | 1 |
Returns (1) | ||
null |
This method changes the AnimationTrack.Speed of an animation. A
positive value for speed plays the animation forward, a negative one plays
it backwards, and 0
pauses it.
A track's initial speed is set as a parameter in
AnimationTrack:Play(). However a track's
AnimationTrack.Speed can be changed during playback using this
method. When speed is equal to 1
, the amount of time an animation
takes to complete is equal to AnimationTrack.Length (in seconds).
When is adjusted, then the actual time it will take a track to play can be computed by dividing the length by the speed. AnimationTrack.Speed is a unitless quantity.
Thread safety | Unsafe |
---|
History 4
- 573 Change ReturnType of AdjustSpeed from void to null
- 570 Change Tags of AdjustSpeed from [] to [CustomLuaState]
- 462 Change ThreadSafety of AdjustSpeed from to Unsafe
- 47 Add AdjustSpeed
AdjustWeight
Parameters (2) | Default | |
---|---|---|
weight | float | 1 |
fadeTime | float | 0.100000001 |
Returns (1) | ||
null |
Changes the weight of an animation, with the optional fadeTime
parameter
determining how long it takes for AnimationTrack.WeightCurrent to
reach AnimationTrack.WeightTarget.
When weight is set in an AnimationTrack it does not change
instantaneously but moves from AnimationTrack.WeightCurrent to
AnimationTrack.WeightTarget. The time it takes to do this is
determined by the fadeTime
parameter given when the animation is played,
or the weight is adjusted.
The animation weighting system is used to determine how
AnimationTracks playing at the same priority are
blended together. The default weight is 1
, and no movement will be
visible on an AnimationTrack with a weight of 0
. The pose that
is shown at any point in time is determined by the weighted average of all
the Poses and the AnimationTrack.WeightCurrent of
each AnimationTrack. See below for an example of animation
blending in practice. In most cases blending animations is not required
and using AnimationTrack.Priority is more suitable.
Thread safety | Unsafe |
---|
History 4
- 573 Change ReturnType of AdjustWeight from void to null
- 570 Change Tags of AdjustWeight from [] to [CustomLuaState]
- 462 Change ThreadSafety of AdjustWeight from to Unsafe
- 47 Add AdjustWeight
Animation
Type | Default | |
---|---|---|
Animation |
The Animation object that was used to create this AnimationTrack. To create an AnimationTrack, you must load an Animation object onto an Animator using the Animator:LoadAnimation() method.
Thread safety | ReadSafe |
---|---|
Category | Data |
Loaded/Saved | false |
DidLoop
Parameters (0) | ||
---|---|---|
No parameters. |
This event fires whenever a looped AnimationTrack completes a loop, on the next update.
Currently it may also fire at the exact end of a non looped animation track but this behavior should not be relied upon.
Thread safety | Unsafe |
---|
Ended
Parameters (0) | ||
---|---|---|
No parameters. |
Fires when the AnimationTrack is completely done moving anything in the world, meaning the animation has finished playing, the "fade out" is finished, and the subject is in a neutral pose.
You can use this to take action when the animation track's subject is back in a neutral pose that's unaffected by the AnimationTrack or to clean up the AnimationTrack.
Thread safety | Unsafe |
---|
GetMarkerReachedSignal
Parameters (1) | ||
---|---|---|
name | string | |
Returns (1) | ||
RBXScriptSignal |
This method returns an event similar to the AnimationTrack.KeyframeReached event, except it only fires when a specified KeyframeMarker has been hit in an animation. The difference allows for greater control of when the event will fire.
To learn more about using this method, see here.
See Also
- KeyframeMarker
- AnimationTrack, controls the playback of an animation on a Humanoid or AnimationController
- Keyframe, holds the Poses applied to joints in a Model at a given point of time in an animation
- Keyframe:AddMarker()
- Keyframe:RemoveMarker()
- Keyframe:GetMarkers()
Thread safety | Unsafe |
---|
History 2
- 462 Change ThreadSafety of GetMarkerReachedSignal from to Unsafe
- 366 Add GetMarkerReachedSignal
GetTargetInstance
Parameters (1) | ||
---|---|---|
name | string | |
Returns (1) | ||
Instance |
Thread safety | Unsafe |
---|
History 1
- 665 Add GetTargetInstance
GetTargetNames
Parameters (0) | ||
---|---|---|
No parameters. | ||
Returns (1) | ||
Array |
Thread safety | Unsafe |
---|
History 1
- 665 Add GetTargetNames
GetTimeOfKeyframe
Parameters (1) | ||
---|---|---|
keyframeName | string | |
Returns (1) | ||
double |
Returns the time position of the first Keyframe of the given name in an AnimationTrack. If multiple Keyframes share the same name, it will return the earliest one in the animation.
This method will return an error if it is uses with an invalid keyframe name (one that does not exist for example) or if the underlying Animation has not yet loaded. To address this make sure only correct keyframe names are used and the animation has loaded before calling this method.
To check if the animation has loaded, verify that the AnimationTrack.Length is greater than zero.
Thread safety | Unsafe |
---|
History 2
- 462 Change ThreadSafety of GetTimeOfKeyframe from to Unsafe
- 206 Add GetTimeOfKeyframe
IsPlaying
Type | Default | |
---|---|---|
bool |
A read-only property that returns true when the AnimationTrack is playing.
This property can be used to check if an animation is already playing before playing it (as that would cause it to restart). If you want to obtain all playing AnimationTracks on an Animator or a Humanoid, they should use Animator:GetPlayingAnimationTracks()
Thread safety | ReadSafe |
---|---|
Category | Data |
Loaded/Saved | false |
KeyframeReached
Parameters (1) | |
---|---|
keyframeName | string |
Fires every time playback of an AnimationTrack reaches a
Keyframe that does not have the default name of Keyframe
. This
event lets you run code at predefined points in an animation (set by
Keyframe names).
Keyframe names do not need to be unique. For example, if an
animation has three keyframes named Particles
, this event will fire each
time one of these keyframes is reached.
Keyframe names can be set in the Animation Editor when creating or editing an animation. They cannot however be set by a Script on an existing animation prior to playing it.
Thread safety | Unsafe |
---|
History 2
- 462 Change ThreadSafety of KeyframeReached from to Unsafe
- 47 Add KeyframeReached
Length
Type | Default | |
---|---|---|
float |
A read-only property that returns the length (in seconds) of an
AnimationTrack. This will return 0
until the animation has fully
loaded and thus may not be immediately available.
When the AnimationTrack.Speed of an AnimationTrack is
equal to 1
, the animation will take AnimationTrack.Length (in
seconds) to complete.
Thread safety | ReadSafe |
---|---|
Category | Data |
Loaded/Saved | false |
Looped
Type | Default | |
---|---|---|
bool |
This property sets whether the animation will repeat after finishing. If it is changed while playing the result will take effect after the animation finishes.
This property defaults to how it was set in the Animation Editor. However, this property can be changed, allowing control over the AnimationTrack while it is running. This property also correctly handles animations played in reverse (negative AnimationTrack.Speed). After the first keyframe is reached, it will restart at the last keyframe.
Thread safety | ReadSafe |
---|---|
Category | Data |
Loaded/Saved | false |
Play
Parameters (3) | Default | |
---|---|---|
fadeTime | float | 0.100000001 |
weight | float | 1 |
speed | float | 1 |
Returns (1) | ||
null |
When AnimationTrack:Play() is called the track's animation will
begin playing and the weight of the animation will increase from 0
to the
specified weight
(defaults to 1
) over the specified fadeTime
.
The speed the AnimationTrack will play at is determined by the
speed parameter (defaults to 1
). When the speed is equal to 1
the number
of seconds the track will take to complete is equal to the track's
AnimationTrack.Length property. For example, a speed of 2
will
cause the track to play twice as fast.
The weight and speed of the animation can also be changed after the animation has begun playing by using the AnimationTrack:AdjustWeight() and AnimationTrack:AdjustSpeed() methods.
If you want to start the animation at a specific point using AnimationTrack.TimePosition, it's important the animation is played before this is done.
Thread safety | Unsafe |
---|
Priority
Type | Default | |
---|---|---|
AnimationPriority |
This property sets the priority of an AnimationTrack. Depending on what this is set to, playing multiple animations at once will look to this property to figure out which Keyframe poses should be played over one another. It uses AnimationPriority which has 7 priority levels:
Properly set animation priorities, either through the Animation Editor or through this property, allow multiple animations to be played without them clashing. Where two playing animations direct the target to move the same limb in different ways, the AnimationTrack with the highest priority will show. If both animations have the same priority, the weights of the tracks will be used to combine the animations.
Thread safety | ReadSafe |
---|---|
Category | Data |
Loaded/Saved | true |
SetTargetInstance
Parameters (2) | ||
---|---|---|
name | string | |
target | Instance | |
Returns (1) | ||
null |
Thread safety | Unsafe |
---|
History 1
- 665 Add SetTargetInstance
Speed
Type | Default | |
---|---|---|
float |
This read-only property gives the current playback speed of the
AnimationTrack. When equal to 1
, the amount of time an animation
takes to complete is equal to AnimationTrack.Length, in seconds.
If the speed is adjusted through AnimationTrack:AdjustSpeed(), the actual time it will take a track to play can be computed by dividing the length by the speed. Speed is a unitless quantity.
Thread safety | ReadSafe |
---|---|
Category | Data |
Loaded/Saved | false |
Stop
Parameters (1) | Default | |
---|---|---|
fadeTime | float | 0.100000001 |
Returns (1) | ||
null |
Stops the AnimationTrack. Once called, the weight of the animation
will move towards zero over a length of time specified by the optional
fadeTime
parameter. For example, if Stop()
is called with a fadeTime
of 2
, it will take two seconds for the weight of the track to reach zero
and its effects completely end. Please note this will be the case
regardless of the initial weight of the animation.
It is not recommended to use a fadeTime
of 0
in an attempt to override
this effect and end the animation immediately for Motor6Ds
that have their Motor.MaxVelocity set to zero, as this causes the
joints to freeze in place. If it must end immediately, ensure the
Motor.MaxVelocity of Motor6Ds in your rig are high
enough for them to snap properly.
Thread safety | Unsafe |
---|
Stopped
Parameters (0) | ||
---|---|---|
No parameters. |
Fires whenever the AnimationTrack finishes playing.
This event has a number of uses. It can be used to wait until an AnimationTrack has stopped before continuing (for example, if chaining a series of animations to play after each other). It can also be used to clean up any Instances created during the animation playback.
Thread safety | Unsafe |
---|
TimePosition
Type | Default | |
---|---|---|
float |
Returns the position in time in seconds that an AnimationTrack is
through playing its source animation. Can be set to make the track jump to
a specific moment in the animation, but the AnimationTrack must be
playing to do so. It can also be used in combination with
AnimationTrack:AdjustSpeed() to freeze the animation at a desired
point by setting speed to 0
.
Thread safety | ReadSafe |
---|---|
Category | Data |
Loaded/Saved | true/false |
History 4
- 553 Change Default of TimePosition from to
- 486 Change ThreadSafety of TimePosition from ReadOnly to ReadSafe
- 462 Change ThreadSafety of TimePosition from to ReadOnly
- 206 Add TimePosition
WeightCurrent
Type | Default | |
---|---|---|
float |
When weight is set in an AnimationTrack it does not change
instantaneously but moves from AnimationTrack.WeightCurrent to
AnimationTrack.WeightTarget. The time it takes to do this is
determined by the fadeTime
parameter given when the animation is played,
or the weight is adjusted.
AnimationTrack.WeightCurrent can be checked against
AnimationTrack.WeightTarget to see if the desired weight has been
reached. Note that these values should not be checked for equality with
the ==
operator, as both of these values are floats. To see if
AnimationTrack.WeightCurrent has reached the target weight, it is
recommended to see if the distance between those values is sufficiently
small.
Thread safety | ReadSafe |
---|---|
Category | Data |
Loaded/Saved | false |
History 4
- 553 Change Default of WeightCurrent from to
- 486 Change ThreadSafety of WeightCurrent from ReadOnly to ReadSafe
- 462 Change ThreadSafety of WeightCurrent from to ReadOnly
- 299 Add WeightCurrent
WeightTarget
Type | Default | |
---|---|---|
float |
This read-only property gives the current weight of the
AnimationTrack. It has a default value of 1
and is set when
AnimationTrack:Play(), AnimationTrack:Stop() or
AnimationTrack:AdjustWeight() is called. When weight is set in an
AnimationTrack it does not change instantaneously but moves from
AnimationTrack.WeightCurrent to
AnimationTrack.WeightTarget. The time it takes to do this is
determined by the fadeTime
parameter given when the animation is played,
or the weight is adjusted.
AnimationTrack.WeightCurrent can be checked against
AnimationTrack.WeightTarget to see if the desired weight has been
reached. Note that these values should not be checked for equality with
the ==
operator, as both of these values are floats. To see if
AnimationTrack.WeightCurrent has reached the target weight, it is
recommended to see if the distance between those values is sufficiently
small.
Thread safety | ReadSafe |
---|---|
Category | Data |
Loaded/Saved | false |
History 4
- 553 Change Default of WeightTarget from to
- 486 Change ThreadSafety of WeightTarget from ReadOnly to ReadSafe
- 462 Change ThreadSafety of WeightTarget from to ReadOnly
- 299 Add WeightTarget