PcoWSkbVqDnWTu_dm2ix
We use cookies on this site to enhance your user experience
Collapse Sidebar

Length

AnimationTrack

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.


Code Samples


Playing Animation for a Specific Duration

The following function will play an AnimationTrack for a specific duration. This is done by changing the speed of the animation to the length of the animation divided by the desired playback duration. This could be used in situations where a developer wants to play a standard animation for different duration (for example, recharging different abilities).

function playAnimationForDuration(animationTrack, duration)
	local speed = animationTrack.Length / duration
	animationTrack:AdjustSpeed(speed)
	animationTrack:Play()
end