rojo/.cursor/rules/roblox/reference/engine/classes/AnimationTrack.yaml
2026-02-02 12:08:47 -06:00

770 lines
26 KiB
YAML

# This file is automatically generated. Please don't edit it manually.
# To submit a bug report on the content, see
# https://devforum.roblox.com/c/bug-reports/documentation-issues/72
name: AnimationTrack
type: class
memory_category: Animation
summary: |
Controls the playback of an animation on an `Class.Animator`.
description: |
Controls the playback of an animation on an `Class.Animator`. This object
cannot be created, instead it is returned by the
`Class.Animator:LoadAnimation()` method.
code_samples: []
inherits:
- Instance
descendants: []
tags:
- NotCreatable
deprecation_message: ''
properties:
- name: AnimationTrack.Animation
summary: |
The `Class.Animation` object that was used to create this
`Class.AnimationTrack`.
description: |
The `Class.Animation` object that was used to create this
`Class.AnimationTrack`. To create an `Class.AnimationTrack`, you must load
an `Class.Animation` object onto an `Class.Animator` using the
`Class.Animator:LoadAnimation()` method.
code_samples:
- AnimationPlayed
type: Animation
tags:
- ReadOnly
- NotReplicated
deprecation_message: ''
security:
read: None
write: None
thread_safety: ReadSafe
category: Data
serialization:
can_load: false
can_save: false
capabilities:
- Animation
- name: AnimationTrack.IsPlaying
summary: |
A read-only property that returns true when the `Class.AnimationTrack` is
playing.
description: |
A read-only property that returns true when the `Class.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 `Class.AnimationTrack|AnimationTracks` on an
`Class.Animator` or a `Class.Humanoid`, they should use
`Class.Animator:GetPlayingAnimationTracks()`
code_samples:
- AnimationTrack-IsPlaying
type: boolean
tags:
- ReadOnly
- NotReplicated
deprecation_message: ''
security:
read: None
write: None
thread_safety: ReadSafe
category: Data
serialization:
can_load: false
can_save: false
capabilities:
- Animation
- name: AnimationTrack.Length
summary: |
A read-only property that returns the length (in seconds) of an
`Class.AnimationTrack`. This will return `0` until the animation has fully
loaded and thus may not be immediately available.
description: |
A read-only property that returns the length (in seconds) of an
`Class.AnimationTrack`. This will return `0` until the animation has fully
loaded and thus may not be immediately available.
When the `Class.AnimationTrack.Speed` of an `Class.AnimationTrack` is
equal to `1`, the animation will take `Class.AnimationTrack.Length` (in
seconds) to complete.
code_samples:
- Animation-Speed-2
type: float
tags:
- ReadOnly
- NotReplicated
deprecation_message: ''
security:
read: None
write: None
thread_safety: ReadSafe
category: Data
serialization:
can_load: false
can_save: false
capabilities:
- Animation
- name: AnimationTrack.Looped
summary: |
Sets whether the animation will repeat after finishing. If it is changed
while playing the result will take effect after the animation finishes.
description: |
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](../../../animation/editor.md). However, this property
can be changed, allowing control over the `Class.AnimationTrack` while it
is running. This property also correctly handles animations played in
reverse (negative `Class.AnimationTrack.Speed`). After the first keyframe
is reached, it will restart at the last keyframe.
code_samples:
- Animation-Looping
- AnimationTrack-DidLoop
type: boolean
tags: []
deprecation_message: ''
security:
read: None
write: None
thread_safety: ReadSafe
category: Data
serialization:
can_load: false
can_save: false
capabilities:
- Animation
- name: AnimationTrack.Priority
summary: |
Sets the priority of an `Class.AnimationTrack`. Depending on what this is
set to, playing multiple animations at once will look to this property to
figure out which `Class.Keyframe` `Class.Pose|Poses` should be played over
one another.
description: |
This property sets the priority of an `Class.AnimationTrack`. Depending on
what this is set to, playing multiple animations at once will look to this
property to figure out which `Class.Keyframe` poses should be played over
one another. It uses `Enum.AnimationPriority` which has 7 priority levels:
1. `Enum.AnimationPriority|Action4` (highest priority)
2. `Enum.AnimationPriority|Action3`
3. `Enum.AnimationPriority|Action2`
4. `Enum.AnimationPriority|Action`
5. `Enum.AnimationPriority|Movement`
6. `Enum.AnimationPriority|Idle`
7. `Enum.AnimationPriority|Core` (lowest priority)
Properly set animation priorities, either through the
[Animation Editor](../../../animation/editor.md) 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 `Class.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.
code_samples: []
type: AnimationPriority
tags: []
deprecation_message: ''
security:
read: None
write: None
thread_safety: ReadSafe
category: Data
serialization:
can_load: true
can_save: true
capabilities:
- Animation
- name: AnimationTrack.Speed
summary: |
Read-only property that gives the current playback speed of the
`Class.AnimationTrack`.
description: |
This read-only property gives the current playback speed of the
`Class.AnimationTrack`. When equal to `1`, the amount of time an animation
takes to complete is equal to `Class.AnimationTrack.Length`, in seconds.
If the speed is adjusted through `Class.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.
code_samples:
- Animation-Speed
- Animation-Speed-2
type: float
tags:
- ReadOnly
- NotReplicated
deprecation_message: ''
security:
read: None
write: None
thread_safety: ReadSafe
category: Data
serialization:
can_load: false
can_save: false
capabilities:
- Animation
- name: AnimationTrack.TimePosition
summary: |
Returns the position in time in seconds that an `Class.AnimationTrack` is
through playing its source animation. Can be set to make the track jump to
a specific moment in the animation.
description: |
Returns the position in time in seconds that an `Class.AnimationTrack` is
through playing its source animation. Can be set to make the track jump to
a specific moment in the animation, but the `Class.AnimationTrack` must be
playing to do so. It can also be used in combination with
`Class.AnimationTrack:AdjustSpeed()` to freeze the animation at a desired
point by setting speed to `0`.
code_samples:
- Animation-TimePosition
type: float
tags:
- NotReplicated
deprecation_message: ''
security:
read: None
write: None
thread_safety: ReadSafe
category: Data
serialization:
can_load: true
can_save: false
capabilities:
- Animation
- name: AnimationTrack.WeightCurrent
summary: |
Read-only property that gives the current weight of the
`Class.AnimationTrack`.
description: |
When weight is set in an `Class.AnimationTrack` it does not change
instantaneously but moves from `Class.AnimationTrack.WeightCurrent` to
`Class.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.
`Class.AnimationTrack.WeightCurrent` can be checked against
`Class.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
`Class.AnimationTrack.WeightCurrent` has reached the target weight, it is
recommended to see if the distance between those values is sufficiently
small.
code_samples:
- AnimationWeight
type: float
tags:
- ReadOnly
- NotReplicated
deprecation_message: ''
security:
read: None
write: None
thread_safety: ReadSafe
category: Data
serialization:
can_load: false
can_save: false
capabilities:
- Animation
- name: AnimationTrack.WeightTarget
summary: |
Read-only property that gives the current weight of the
`Class.AnimationTrack`.
description: |
This read-only property gives the current weight of the
`Class.AnimationTrack`. It has a default value of `1` and is set when
`Class.AnimationTrack:Play()`, `Class.AnimationTrack:Stop()` or
`Class.AnimationTrack:AdjustWeight()` is called. When weight is set in an
`Class.AnimationTrack` it does not change instantaneously but moves from
`Class.AnimationTrack.WeightCurrent` to
`Class.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.
`Class.AnimationTrack.WeightCurrent` can be checked against
`Class.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
`Class.AnimationTrack.WeightCurrent` has reached the target weight, it is
recommended to see if the distance between those values is sufficiently
small.
code_samples:
- AnimationWeight
type: float
tags:
- ReadOnly
- NotReplicated
deprecation_message: ''
security:
read: None
write: None
thread_safety: ReadSafe
category: Data
serialization:
can_load: false
can_save: false
capabilities:
- Animation
methods:
- name: AnimationTrack:AdjustSpeed
summary: |
Changes the `Class.AnimationTrack.Speed` of an animation. A positive value
for speed plays the animation forward, a negative one plays it backwards,
and `0` pauses it.
description: |
This method changes the `Class.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
`Class.AnimationTrack:Play()`. However a track's
`Class.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 `Class.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. `Class.AnimationTrack.Speed`
is a unitless quantity.
code_samples:
- Animation-Speed-2
- Animation-Speed
parameters:
- name: speed
type: float
default: 1
summary: |
The playback speed the animation is to be changed to.
returns:
- type: ()
summary: ''
tags:
- CustomLuaState
deprecation_message: ''
security: None
thread_safety: Unsafe
capabilities:
- Animation
- name: AnimationTrack:AdjustWeight
summary: |
Changes the weight of an animation, with the optional `fadeTime` parameter
determining how long it takes for `Class.AnimationTrack.WeightCurrent` to
reach `Class.AnimationTrack.WeightTarget`.
description: |
Changes the weight of an animation, with the optional `fadeTime` parameter
determining how long it takes for `Class.AnimationTrack.WeightCurrent` to
reach `Class.AnimationTrack.WeightTarget`.
When weight is set in an `Class.AnimationTrack` it does not change
instantaneously but moves from `Class.AnimationTrack.WeightCurrent` to
`Class.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
`Class.AnimationTrack|AnimationTracks` playing at the same priority are
blended together. The default weight is `1`, and no movement will be
visible on an `Class.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 `Class.Pose|Poses` and the `Class.AnimationTrack.WeightCurrent` of
each `Class.AnimationTrack`. See below for an example of animation
blending in practice. In most cases blending animations is not required
and using `Class.AnimationTrack.Priority` is more suitable.
code_samples:
- AnimationTrack-Change-Weight
parameters:
- name: weight
type: float
default: 1
summary: |
The weight the animation is to be changed to.
- name: fadeTime
type: float
default: 0.100000001
summary: |
The duration of time that the animation will fade between the old
weight and the new weight for.
returns:
- type: ()
summary: ''
tags:
- CustomLuaState
deprecation_message: ''
security: None
thread_safety: Unsafe
capabilities:
- Animation
- name: AnimationTrack:GetMarkerReachedSignal
summary: |
Returns an `Datatype.RBXScriptSignal` (event) that fires when a specified
`Class.KeyframeMarker` has been hit in an `Class.Animation|animation`.
description: |
This method returns an `Datatype.RBXScriptSignal` (event) similar to the
`Class.AnimationTrack.KeyframeReached` event, except it only fires when a
specified `Class.KeyframeMarker` has been hit in an
`Class.Animation|animation`. The difference allows for greater control of
when the event will fire.
To learn more about using this method, see
[here](../../../animation/events.md).
#### See Also
- `Class.KeyframeMarker`
- `Class.AnimationTrack`, controls the playback of an animation on a
`Class.Humanoid` or `Class.AnimationController`
- `Class.Keyframe`, holds the `Class.Pose|Poses` applied to joints in a
`Class.Model` at a given point of time in an animation
- `Class.Keyframe:AddMarker()`
- `Class.Keyframe:RemoveMarker()`
- `Class.Keyframe:GetMarkers()`
code_samples:
- listening-to-keyframemarkers
parameters:
- name: name
type: string
default:
summary: |
The name of the `Class.KeyframeMarker` the signal is being created
for. Not to be confused with the name of the `Class.Keyframe`.
returns:
- type: RBXScriptSignal
summary: |
The signal created and fired when the animation reaches the created
`Class.KeyframeMarker`.
tags: []
deprecation_message: ''
security: None
thread_safety: Unsafe
capabilities:
- Animation
- name: AnimationTrack:GetParameter
summary: ''
description: ''
code_samples: []
parameters:
- name: key
type: string
default:
summary: ''
returns:
- type: Variant
summary: ''
tags: []
deprecation_message: ''
security: None
thread_safety: Unsafe
capabilities:
- Animation
- name: AnimationTrack:GetParameterDefaults
summary: ''
description: ''
code_samples: []
parameters: []
returns:
- type: Dictionary
summary: ''
tags: []
deprecation_message: ''
security: None
thread_safety: Unsafe
capabilities:
- Animation
- name: AnimationTrack:GetTargetInstance
summary: ''
description: ''
code_samples: []
parameters:
- name: name
type: string
default:
summary: ''
returns:
- type: Instance
summary: ''
tags: []
deprecation_message: ''
security: None
thread_safety: Unsafe
capabilities:
- Animation
- name: AnimationTrack:GetTargetNames
summary: ''
description: ''
code_samples: []
parameters: []
returns:
- type: Array
summary: ''
tags: []
deprecation_message: ''
security: None
thread_safety: Unsafe
capabilities:
- Animation
- name: AnimationTrack:GetTimeOfKeyframe
summary: |
Returns the time position of the first `Class.Keyframe` of the given name
in an `Class.AnimationTrack`.
description: |
Returns the time position of the first `Class.Keyframe` of the given name
in an `Class.AnimationTrack`. If multiple `Class.Keyframe|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
`Class.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
`Class.AnimationTrack.Length` is greater than zero.
code_samples:
- Animation-GetTimeOfKeyframe
parameters:
- name: keyframeName
type: string
default:
summary: |
The name associated with the `Class.Keyframe` to be found.
returns:
- type: double
summary: |
The time, in seconds, the `Class.Keyframe` occurs at normal playback
speed.
tags: []
deprecation_message: ''
security: None
thread_safety: Unsafe
capabilities:
- Animation
- name: AnimationTrack:Play
summary: |
Plays the `Class.AnimationTrack`. Once called an `Class.AnimationTrack`
will play with the specified `fadeTime`, weight and speed.
description: |
When `Class.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 `Class.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
`Class.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
`Class.AnimationTrack:AdjustWeight()` and
`Class.AnimationTrack:AdjustSpeed()` methods.
If you want to start the animation at a specific point using
`Class.AnimationTrack.TimePosition`, it's important the animation is
played before this is done.
code_samples:
- Animation-Speed-2
- Animation-TimePosition
parameters:
- name: fadeTime
type: float
default: 0.100000001
summary: |
The duration of time that the animation's weight should be faded in
for.
- name: weight
type: float
default: 1
summary: |
The weight the animation is to be played at.
- name: speed
type: float
default: 1
summary: |
The playback speed of the animation.
returns:
- type: ()
summary: ''
tags:
- CustomLuaState
deprecation_message: ''
security: None
thread_safety: Unsafe
capabilities:
- Animation
- name: AnimationTrack:SetParameter
summary: ''
description: ''
code_samples: []
parameters:
- name: key
type: string
default:
summary: ''
- name: value
type: Variant
default:
summary: ''
returns:
- type: ()
summary: ''
tags: []
deprecation_message: ''
security: None
thread_safety: Unsafe
capabilities:
- Animation
- name: AnimationTrack:SetTargetInstance
summary: ''
description: ''
code_samples: []
parameters:
- name: name
type: string
default:
summary: ''
- name: target
type: Instance
default:
summary: ''
returns:
- type: ()
summary: ''
tags: []
deprecation_message: ''
security: None
thread_safety: Unsafe
capabilities:
- Animation
- name: AnimationTrack:Stop
summary: |
Stops the `Class.AnimationTrack`.
description: |
Stops the `Class.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 `Class.Motor6D|Motor6Ds`
that have their `Class.Motor.MaxVelocity` set to zero, as this causes the
joints to freeze in place. If it must end immediately, ensure the
`Class.Motor.MaxVelocity` of `Class.Motor6D|Motor6Ds` in your rig are high
enough for them to snap properly.
code_samples:
- AnimationTrack-Stop
parameters:
- name: fadeTime
type: float
default: 0.100000001
summary: |
The time, in seconds, for which animation weight is to be faded out
over.
returns:
- type: ()
summary: ''
tags:
- CustomLuaState
deprecation_message: ''
security: None
thread_safety: Unsafe
capabilities:
- Animation
events:
- name: AnimationTrack.DidLoop
summary: |
Fires when an `Class.AnimationTrack` loops on the next update following
the end of the previous animation loop.
description: |
This event fires whenever a looped `Class.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.
code_samples:
- AnimationTrack-DidLoop
parameters: []
tags: []
deprecation_message: ''
security: None
capabilities:
- Animation
- name: AnimationTrack.Ended
summary: |
Fires when the `Class.AnimationTrack` is completely done moving anything
in the world.
description: |
Fires when the `Class.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 `Class.AnimationTrack` or to
clean up the `Class.AnimationTrack`.
code_samples:
- AnimationTrack-Ended
parameters: []
tags: []
deprecation_message: ''
security: None
capabilities:
- Animation
- name: AnimationTrack.KeyframeReached
summary: |
Fires every time playback of an `Class.AnimationTrack` reaches a
`Class.Keyframe` that does not have the default name of `Keyframe`.
description: |
Fires every time playback of an `Class.AnimationTrack` reaches a
`Class.Keyframe` that does not have the default name of `Keyframe`. This
event lets you run code at predefined points in an animation (set by
`Class.Keyframe` names).
`Class.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.
`Class.Keyframe` names can be set in the
[Animation Editor](../../../animation/editor.md) when creating or editing
an animation. They cannot however be set by a `Class.Script` on an
existing animation prior to playing it.
code_samples: []
parameters:
- name: keyframeName
type: string
default:
summary: |
The name of the `Class.Keyframe` reached.
tags: []
deprecation_message: |
This event has been superseded by the
`Class.AnimationTrack:GetMarkerReachedSignal()` method.
security: None
capabilities:
- Animation
- name: AnimationTrack.Stopped
summary: |
Fires when the `Class.AnimationTrack` finishes playing. The AnimationTrack
might still animate the subject while the animation "fades out". To catch
when the AnimationTrack is completely done moving anything in the world,
use the `Class.AnimationTrack.Ended` event.
description: |
Fires whenever the `Class.AnimationTrack` finishes playing.
This event has a number of uses. It can be used to wait until an
`Class.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 `Class.Instance|Instances` created during the
animation playback.
code_samples:
- AnimationTrack-Stopped
parameters: []
tags: []
deprecation_message: ''
security: None
capabilities:
- Animation
callbacks: []