AnimationTrack
AnimationTrack : Instance
Overview
Properties
Animation
Animation
The Animation
object associated with this track, which contains the animation data to be played or processed.
Code Samples
print(AnimationTrack.Animation)
IsPlaying
bool
This property indicates whether the AnimationTrack is currently playing. If true
, the animation is playing; if false
, it is paused or stopped.
Code Samples
AnimationTrack:Play()
if AnimationTrack.IsPlaying then
print("DoSomething")
end
Length
number
This property represents the length of the animation in seconds. It indicates the total duration of the animation from its start to its end.
Code Samples
print(AnimationTrack.Length)
Looped
bool
Indicates whether the animation should repeat after reaching the end. If set to true
, the animation will loop continuously. If set to false
, the animation will stop after one full playthrough.
Code Samples
AnimationTrack.Looped = true
Priority
Enum.AnimationPriority
This property defines the relative importance of the animation compared to others. Animations with higher priority will override those with lower priority.
Code Samples
AnimationTrack.Priority = Enum.AnimationPriority.Movement
AnimationTrack:Play()
Speed
number
Currently not supported.
Code Samples
TimePosition
number
Currently not supported.
Code Samples
WeightCurrent
number
Currently not supported.
Code Samples
WeightTarget
number
Currently not supported.
Code Samples
Methods
AdjustSpeed
Parameters
number
InSpeed
Return
void
Code Samples
AnimationTrack:AdjustSpeed(3)
AdjustWeight
Currently not supported.
Parameters
number
InWeight
number
InFadeTime
Return
void
Code Samples
GetMarkerReachedSignal
This method, GetMarkerReachedSignal
, retrieves a signal that is triggered when the specified marker is reached during an animation playback. It takes a string parameter InName
which represents the name of the marker to listen for and returns a ULuaScriptSignal
that can be connected to custom event handlers.
Parameters
string
InName
Return
ScriptSignal
Code Samples
local function OnAnimationEvent()
print("OnAnimationEvent")
end
AnimationTrack:GetMarkerReachedSignal("SomeKeyName"):connect(OnAnimationEvent)
GetTimeOfKeyframe
Currently not supported.
Parameters
string
InName
Return
number
Code Samples
Play
The Play method plays an animation by applying fade-in, weight, and speed effects to the specified parameters.
Parameters
number
InFadeTime
number
InWeight
Currently not supported.
number
InSpeed
Return
void
Code Samples
local Players = game:GetService("Players")
local Character = Players.LocalPlayer.Character
local Humanoid = Character:WaitForChild("Humanoid")
local Animation = Instance.new("Animation")
Animation.AnimationId = "ovdrassetid://18850100" -- WinAnimation01
local Animator = Humanoid:FindFirstChild("Animator")
local AnimationTrack = Animator:LoadAnimation(Animation)
AnimationTrack:Play()
Stop
Stops the current animation with an fade-out time of InFadeTime seconds.
Parameters
number
InFadeTime
Currently not supported.
Return
void
Code Samples
AnimationTrack:Stop()
Events
DidLoop
This event triggers whenever the animation loops back to its starting position. Useful for detecting when an animation cycle has completed and has started again.
Parameters
Code Samples
AnimationTrack.Looped = true
local function OnLoopAnimation()
print("The animation looped!")
end
AnimationTrack.DidLoop:Connect(OnLoopAnimation)
AnimationTrack:Play()
Ended
This event triggers when the animation playback ends completely. It is useful for detecting when an animation has finished playing and performing any follow-up actions.
Parameters
Code Samples
local function OnEnded()
print("The animation has ended!")
end
AnimationTrack.Ended:Connect(OnEnded)
KeyframeReached
This event triggers when a specified keyframe within the animation is reached during playback. It is useful for executing code or handling logic at specific points in the animation timeline, such as syncing actions or triggering effects.
Parameters
string
InKeyframeReached
Code Samples
local function OnKeyframeReached(keyframeName)
print(keyframeName)
end
AnimationTrack.KeyframeReached:Connect(OnKeyframeReached)
Stopped
This event triggers when the animation playback is completely stopped, either manually or programmatically. It is useful for detecting when an animation has been interrupted or intentionally halted, allowing for cleanup or handling related logic.
Parameters
Code Samples
local function OnStopped()
print("The animation has been stopped!")
end
AnimationTrack.Stopped:Connect(OnStopped)
See also
Character AnimationLast updated