Animation

An Animation is a set of keyframes groups that can be used to animate any object or group of objects, such as animating a character or creating a cutscene.

Each keyframes group is bound to animating one object, it can be toggled on or off individually to disable part of an animation.
For example, a running animation could temporarily toggle off the keyframes group bound to an arm to simultaneously play a wave animation on that arm.

Constructors

Animation ( string name optional, table config optional )

When created, an Animation can be given a name and a set of optional configuration { duration, speed, count}.
They are used to initialize the corresponding properties Duration, Speed and Count.

Functions

nil AddFrameInGroup ( string name, number weight, table transform )

Add a keyframe to the group identified by its name, at a given weight, for a transformation of any or all of position, rotation and scale through the last parameter { position, rotation, scale }.

The weight can be any number, allowing you to organize keyframes relative to each others' weight.
Keyframes are then played in order of increasing weight.

Note that when the animation is played for the first time, keyframes weights are automatically normalized.

Register a function to be called any time the animation is played.

Register a function to be called any time the animation is stopped.

nil Bind ( string name, Object target )

Binds a keyframes group identified by its name to the given object. It means whenever this animation is played, that particular group of keyframes will modify the bound object.

nil Pause ( )

Pauses the animation.

nil Play ( )

Starts or resumes the animation.

Reverse, then starts or resumes the animation.

Unregister a function that was previously registered with AddOnPlayCallback.

Unregister a function that was previously registered with AddOnStopCallback.

nil Stop ( )

Stops and resets the animation.

nil Tick ( )

Steps the animation one tick. This is typically to be called inside Client.Tick or Object.Tick.

⚠️ This needs to be called manually currently. In a future version, it may be done automatically.

nil Toggle ( string name, boolean toggle )

Toggles a keyframes group identified by its name. Whenever this animation is played, that particular group of keyframes will not be used until toggled back on.

Properties

Number of cycles to repeat the animation. The default count of 1 will play a full cycle once. Setting this to 0 will repeat the animation indefenitely.

Duration in seconds of one animation cycle.

Whether or not the animation is currently playing.

Speed of one animation cycle. This is the inverse of Duration, you can choose to set one or the other.