KeyframeSequence
This object stores all of the Keyframes and other data for the animation.
Memory category | Animation |
---|
Member index 4
Removed member index 2
History | Member | |
---|---|---|
497 | Loop: bool | |
497 | Priority: AnimationPriority |
Description
This object stores all the Keyframes for an animation, determines if the animation is looped, and determines its priority against other animations.
What is a KeyframeSequence?
Roblox constructs the animation data it uses in the playback of an animation, referenced by the Animation.AnimationId property from a KeyframeSequence. Every animation refers to a KeyframeSequence or to a CurveAnimation internally. Although, usually created by the Roblox Animation Editor, KeyframeSequence can also be created by other plugins or even manually. Once uploaded to Roblox, Roblox assigns a Content ID that Animations use for the Animation.AnimationId property to refer to the uploaded KeyframeSequence.
Note, in most cases, you do not need to manipulate KeyframeSequences, as the animation editor covers most animation functionality. However, in some cases you may wish to generate an animation from a Script or build your own plugin. However, only Roblox Studio can use a KeyframeSequence created in such a way. If you wish to use such a KeyframeSequence, you will need to upload it to Roblox as described below.
KeyframeSequence Properties
KeyframeSequence.Priority and KeyframeSequence.Loop save the priority and looped animation settings for the sequence. Note that AnimationTrack properties can eventually overwrite these properties at playback time.
The last Keyframe in the sequence, meaning the Keyframe with the highest Keyframe.Time property, determines the length of an animation.
KeyframeSequence Structure
KeyframeSequences act as a container that hold Keyframes. Keyframes represent a 'key' frame in the animation, that are interpolated between during playback.
Keyframes contain Poses. Poses, specific to each BasePart being animated, contain the CFrame applied to the Motor6D connecting two parts. Poses match the BasePart they correspond with by name and apply their data to the Motor6D with this same-named part identified as Motor6D.P1 . For this reason, animations require distinct part names to play correctly.
Poses follow a structure based on joint hierarchy. The parent of each Pose corresponds to the Pose of the part it is attached to. In practice, this means the poses branch out from the root part. See below for a visual example.
Using KeyframeSequences when making animations
You must first upload KeyframeSequences to Roblox before they can be played in an experience. In Studio, right click on the KeyframeSequence and click 'Save to Roblox'. Alternatively, you can use the Plugin:SaveSelectedToRoblox() function. Either method will bring up the animation upload window and allow you to upload your KeyframeSequence as an animation.
In some cases, you may want to preview an Animation before uploading it to the Roblox site. You can generate a temporary id using KeyframeSequenceProvider:RegisterKeyframeSequence(). This will generate a hash id that can be used for localized animation testing.
Obtaining KeyframeSequences
In some cases you may wish to download the KeyframeSequence corresponding to an existing uploaded Animation. You can use AnimationClipProvider:GetAnimationClipAsync() to download an animation.
History 24
- 648 Change ReturnType of GetKeyframes from Objects to Instances
- 573 Change ReturnType of RemoveKeyframe from void to null
- 573 Change ReturnType of AddKeyframe from void to null
- 553 Change Default of from to 2
- 497 Remove Priority
- 497 Remove Loop
- 497 Change Superclass of KeyframeSequence from Instance to AnimationClip
- 486 Change ThreadSafety of Priority from ReadOnly to ReadSafe
- 486 Change ThreadSafety of Loop from ReadOnly to ReadSafe
- 486 Change ThreadSafety of from ReadOnly to ReadSafe
- 469 Change Tags of from [] to [Hidden]
- 462 Change ThreadSafety of RemoveKeyframe from to Unsafe
- 462 Change ThreadSafety of GetKeyframes from to Unsafe
- 462 Change ThreadSafety of AddKeyframe from to Unsafe
- 462 Change ThreadSafety of Priority from to ReadOnly
- 462 Change ThreadSafety of Loop from to ReadOnly
- 462 Change ThreadSafety of from to ReadOnly
- 364 Add
- 47 Add RemoveKeyframe
- 47 Add GetKeyframes
- 47 Add AddKeyframe
- 47 Add Priority
- 47 Add Loop
- 47 Add KeyframeSequence
Members 4
AddKeyframe
Parameters (1) | ||
---|---|---|
keyframe | Instance | |
Returns (1) | ||
null |
This function adds a Keyframe to the KeyframeSequence by parenting it to the KeyframeSequence. It is functionally identical to setting the keyframe's Instance.Parent to the KeyframeSequence.
Note, this function will not error when called with an instance other than a Keyframe as the keyframe parameter and will parent it successfully.
Thread safety | Unsafe |
---|
History 3
- 573 Change ReturnType of AddKeyframe from void to null
- 462 Change ThreadSafety of AddKeyframe from to Unsafe
- 47 Add AddKeyframe
GetKeyframes
Parameters (0) | ||
---|---|---|
No parameters. | ||
Returns (1) | ||
Instances |
GetKeyframes returns an array that contains all Keyframes that have been added to a KeyframeSequence.
Thread safety | Unsafe |
---|
History 3
- 648 Change ReturnType of GetKeyframes from Objects to Instances
- 462 Change ThreadSafety of GetKeyframes from to Unsafe
- 47 Add GetKeyframes
RemoveKeyframe
Parameters (1) | ||
---|---|---|
keyframe | Instance | |
Returns (1) | ||
null |
This function removes a Keyframe from the KeyframeSequence by setting its parent to nil. It is functionally identical to setting the keyframe's parent to nil.
This sets the keyframe's parent to nil
, but does not destroy it. This
means, provided another reference to the keyframe remains, it can be
re-parented later.
Note, this function will not error when called with an Instance other than a Keyframe as the keyframe parameter.
Thread safety | Unsafe |
---|
History 3
- 573 Change ReturnType of RemoveKeyframe from void to null
- 462 Change ThreadSafety of RemoveKeyframe from to Unsafe
- 47 Add RemoveKeyframe
Removed members 2
Loop
Type | Default | |
---|---|---|
bool |
Thread safety | ReadSafe |
---|---|
Category | Data |
Loaded/Saved | true |
Priority
Type | Default | |
---|---|---|
AnimationPriority |
Thread safety | ReadSafe |
---|---|
Category | Data |
Loaded/Saved | true |