API:Class/Keyframe

Filtered-inheritance mode: While this class technically inherits all Instance class members, some (if not all) have been hidden because they serve no purpose for this object.

Animation icon.pngKeyframe : Object Icon.pngInstance

This object is used in Roblox's Animation system to determine a series of poses for joints at a certain point of time.

Properties

Properties [toggle]

floatTime

The frame of Time for the Keyframe.

|RMD member="API:Class/Keyframe/Time"|The frame of Time for the Keyframe.|/RMD|
The frame of Time for the Keyframe.
Inherited from Object Icon.pngInstance:
Ref<Instance>Parent

The hierarchical parent of the object.

|RMD member="API:Class/Instance/Parent"|The hierarchical parent of the object.|/RMD|
The hierarchical parent of the object.

Functions

Functions [toggle]

voidAddPose ( Pose pose )

Sets the pose's parent to the keyframe.

|RMD member="API:Class/Keyframe/AddPose"|Sets the pose's parent to the keyframe.|/RMD|
array<Pose>GetPoses ( )

Functions identically to GetChildren.

|RMD member="API:Class/Keyframe/GetPoses"|Functions identically to GetChildren.|/RMD|
voidRemovePose ( Pose pose )

Removes the specified pose from the Keyframe if it is parented to this Keyframe.

|RMD member="API:Class/Keyframe/RemovePose"|Removes the specified pose from the Keyframe if it is parented to this Keyframe.|/RMD|
AddPose ( Pose pose )
Sets the pose's parent to the keyframe.
Functions identically to GetChildren.
RemovePose ( Pose pose )
Removes the specified pose from the Keyframe if it is parented to this Keyframe.


|RMD member="API:Class/Keyframe"|This object is used in Roblox's Animation system to determine a series of poses for joints at a certain point of time. |/RMD|


Notes

A Keyframe is represented by a hierarchical structure of pose objects representing the CFrame between different joints in a rig. To apply a Keyframe to a rig without running an animation the following code can be used.

local function getJointBetween(part0, part1)
	for _, obj in pairs(part1:GetChildren()) do
		if obj:IsA("Motor6D") and obj.Part0 == part0 then
			return obj
		end
	end
	for _, obj in pairs(part0:GetChildren()) do
		if obj:IsA("Motor6D") and obj.Part1 == part1 then
			return obj
		end
	end
end
 
local function applyKeyFrame(rig, poseKeyframe)	
	local function recurApplyPoses(parentPose, poseObject)
		if parentPose then
			if rig:FindFirstChild(parentPose.Name) and rig:FindFirstChild(poseObject.Name) then
				local joint = getJointBetween(rig[parentPose.Name], rig[poseObject.Name])
				if joint then
					joint.C1 = joint.C1 * poseObject.CFrame:inverse()
				end
			end
		end
		for _, subPose in pairs(poseObject:GetSubPoses()) do
			recurApplyPoses(poseObject, subPose)
		end
	end
	for _, poseObj in pairs(poseKeyframe:GetPoses()) do
		recurApplyPoses(nil, poseObj)
	end
end