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, mode, speed, count}.
They are used to initialize the corresponding properties Duration, Mode, 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 if using AnimationMode.Loop or AnimationMode.Mirror.

Duration in seconds of one animation cycle.

Whether or not the animation is currently playing.

An Animation can function in three modes,
- AnimationMode.Once the animation plays one cycle and stops at the end of its duration.
- AnimationMode.Loop the animation will repeat at the end of each cycle until Stop is called or, if Count is set, for a specific number of cycles
- AnimationMode.Mirror the animation will repeat and reverse at the end of each cycle until Stop is called or, if Count is set, for a specific number of cycles

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