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 (defaults to 0.1).
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
If the developer wants to start the animation at a specific point using
AnimationTrack/TimePosition, it is important the animation is played before this is done.
The duration of time that the animation’s weight should be faded in for.
The weight the animation is to be played at.
The playback speed of the animation.
Freeze Animation at Position
The following code sample includes two functions that demonstrate how AdjustSpeed and TimePosition can be used to freeze an animation at a particular point.
The first function freezes an animation at a particular point in time (defined in seconds). The second freezes at it at a percentage (between 0 or 100) by multiplying the percentage by the track length.
As TimePosition can not be used when an AnimationTrack is not playing, the functions check to make sure the animation is playing before proceeding.
function freezeAnimationAtTime(animationTrack, timePosition) -- Set the speed to 0 to freeze the animation animationTrack:AdjustSpeed(0) if not animationTrack.IsPlaying then -- Play the animation if it is not playing animationTrack:Play() end -- Jump to the desired TimePosition animationTrack.TimePosition = timePosition end function freezeAnimationAtPercent(animationTrack, percentagePosition) -- Set the speed to 0 to freeze the animation animationTrack:AdjustSpeed(0) if not animationTrack.IsPlaying then -- Play the animation if it is not playing animationTrack:Play() end -- Jump to the desired TimePosition animationTrack.TimePosition = (percentagePosition / 100) * animationTrack.Length end
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).