CustomAnimator
A simple class for working with animations.
local playerHumanoidCustomAnimator = CustomAnimator.new(humanoidAnimator)
local track = playerHumanoidCustomAnimator:loadAnimation(animation)
track:Play()
Types
CustomAnimator
Properties
onAnimationLoaded
CustomAnimator InstanceA signal which is fired whenever a new animation is loaded through CustomAnimator:loadAnimation.
Functions
new
Creates and returns a new custom animator object.
animationTrack
CustomAnimator instanceReturns the given loaded animation track from the animation, if found.
onAnimationLoadPromise
CustomAnimator instanceReturns a promise which is resolved once the given animation is loaded via CustomAnimator:loadAnimation.
Automatic promise cancellation
The returned promise will be cancelled if the animator object or the animation controller object this custom animator is connected to, is destroyed.
loadAnimation
CustomAnimator instanceLoads in the given animation
.
tryPlayAnimation
CustomAnimator instanceCustomAnimator:
tryPlayAnimation
(
priority:
Enum.AnimationPriority?
,
fadeTime:
number?
,
weight:
number?
,
speed:
number?
) →
AnimationTrack?
Tries to play the given animation
, if it has been loaded into the custom animator via CustomAnimator:loadAnimation. This
method will return the animation track of the loaded animation
upon successfully playing it, else it'll return nil
.
TIP
You can also setup attributes for fadeTime
, weight
, and speed
in animation
, which will be used incase the
arguments for them aren't specified.
Attribute | Argument |
---|---|
"AnimationPlayFadeTime" |
fadeTime |
"AnimationPlayWeight" |
weight |
"AnimationPlaySpeed" |
speed |
scheduleAnimationToPlayOnLoadPromise
CustomAnimator instanceCustomAnimator:
scheduleAnimationToPlayOnLoadPromise
(
priority:
Enum.AnimationPriority?
,
fadeTime:
number?
,
weight:
number?
,
speed:
number?
) →
Promise
<
>
Plays the given animation
as soon as it is loaded into the custom animator. Returns a promise which is resolved
once the given animation
has finished playing. Additionally, you can cancel the returned promise which in turn
will also stop the animation
from playing any further.
Automatic promise cancellation
-
If this method is called again for the same animation while the previous promise has not yet finished, then the previous promise will be cancelled.
-
The returned promise will be cancelled if the animator object or the animation controller object this custom animator is connected to, is destroyed.
tryStopAnimation
CustomAnimator instance
Tries to stop the given animation
, if it is loaded. Also cancels the promise returned by
CustomAnimator:scheduleAnimationPlayOnLoadPromise for the given animation
, if found.
stopAll
CustomAnimator instanceCustomAnimator:
stopAll
(
fadeTime:
number?
) →
(
)
Stops all loaded animations by calling CustomAnimator:tryStopAnimation on each one of them.
all
CustomAnimator instanceReturns a read only copy dictionary of all animations loaded into the animator object.
cleanupAnimation
CustomAnimator instanceDestroys the animation track of the given animation
if loaded, and removes it from the custom animator.
animator
CustomAnimator instanceReturns the animator associated to the animator object.
destroy
CustomAnimator instanceCustomAnimator:
destroy
(
) →
(
)
Destroys the custom animator object and renders it unusuable. Additionally, CustomAnimator:cleanupAnimationTrack is called on all loaded animation tracks too.