Pose

Show Deprecated

A Pose holds the CFrame applied to the Motor6D connected to its associated BasePart. The part which is controlled depends on the name of the Pose.

Poses are the fundamental building blocks of animations and, with Keyframes, make up KeyframeSequences.

Poses, joints and hierarchy

Although a Pose is assigned to a BasePart by name, the object manipulated during animation playback is actually the Motor6D connected to this part. Animation rigs branch out from the model's root part through such joints.

In a R15 character rig, the root part is the HumanoidRootPart. The LowerTorso is connected to the HumanoidRootPart by the a motor named 'Root'. Therefore, the CFrame of a Pose named 'LowerTorso' in a Keyframe would be applied to the motor named 'Root', and not the LowerTorso itself.

Poses are arranged in a Keyframe based on joint hierarchy. This means, the Pose's CFrame is applied to the motor connecting the part associated with the pose to the part associated with the pose's parent. See below for a visual example of the structure of Poses on a R15 character.

Pose CFrame

The Roblox animation system applies Pose.CFrame to the corresponding Motor6D by manipulating the relative transformation of the motor, the Motor6D.Transform property. The original C0 and C1 values are not changed.

Code Samples

Keyframe Generate Poses

1local function generateKeyframe(model)
2 if not model.PrimaryPart then
3 warn("No primary part set")
4 return
5 end
6
7 local rootPart = model.PrimaryPart:GetRootPart()
8
9 if not rootPart then
10 warn("Root part not found")
11 return
12 end
13
14 local partsAdded = {}
15 partsAdded[rootPart] = true
16
17 local function addPoses(part, parentPose)
18 -- get all of the joints attached to the part
19 for _, joint in pairs(part:GetJoints()) do
20 -- we're only interested in Motor6Ds
21 if joint:IsA("Motor6D") then
22 -- find the connected part
23 local connectedPart = nil
24 if joint.Part0 == part then
25 connectedPart = joint.Part1
26 elseif joint.Part1 == part then
27 connectedPart = joint.Part0
28 end
29 if connectedPart then
30 -- make sure we haven't already added this part
31 if not partsAdded[connectedPart] then
32 partsAdded[connectedPart] = true
33 -- create a pose
34 local pose = Instance.new("Pose")
35 pose.Name = connectedPart.Name
36 parentPose:AddSubPose(pose)
37 -- recurse
38 addPoses(connectedPart, pose)
39 end
40 end
41 end
42 end
43 end
44
45 local keyframe = Instance.new("Keyframe")
46
47 -- populate the keyframe
48 local rootPose = Instance.new("Pose")
49 rootPose.Name = rootPart.Name
50 addPoses(rootPart, rootPose)
51 keyframe:AddPose(rootPose)
52
53 return keyframe
54end
55
56local character = script.Parent
57
58local keyframe = generateKeyframe(character)
59
60print(keyframe)
Keyframe Reset Poses

1local function resetPoses(parent)
2 -- both functions are equivalent to GetChildren
3 local poses = parent:IsA("Keyframe") and parent:GetPoses() or parent:IsA("Pose") and parent:GetSubPoses()
4
5 for _, pose in pairs(poses) do
6 if pose:IsA("Pose") then
7 pose.CFrame = CFrame.new()
8 -- recurse
9 resetPoses(pose)
10 end
11 end
12end

Summary

Properties

This CFrame applies to the Motor6D corresponding with the Pose when the Motor6D.Transform is changed.

Events

Methods

AddSubPose(pose: Instance): void  

Adds a sub Pose to the Pose by parenting it.


Returns an array containing all sub Poses that have been added to a Pose.

RemoveSubPose(pose: Instance): void  

Removes a sub Pose from the Pose by parenting it to nil.

Properties

CFrame

This CFrame applies to the Motor6D corresponding with the Pose when the Motor6D.Transform is changed. The original Motor6D.C0 and Motor6D.C1 values are not changed.

Pose objects are arranged in a Keyframe based on joint hierarchy. This means, that the Pose.CFrame is applied to the motor connecting the part associated with the pose to the part associated with the pose's parent.

Events

Methods

AddSubPose

void

Adds a sub Pose to the Pose by parenting it to it. It is functionally identical to setting the new pose's Instance.Parent to the pose.

Note, this function will not error when an instance other than a Pose is given as the pose parameter and will parent it successfully.

Parameters

pose: Instance

The Pose to be added.


Returns

void

Code Samples

Keyframe Add/Remove Pose

1local keyframe = Instance.new("Keyframe")
2keyframe.Parent = workspace
3
4local pose = Instance.new("Pose")
5pose.EasingStyle = Enum.PoseEasingStyle.Cubic
6pose.EasingDirection = Enum.PoseEasingDirection.Out
7
8local pose2 = Instance.new("Pose")
9pose2.EasingStyle = Enum.PoseEasingStyle.Cubic
10pose2.EasingDirection = Enum.PoseEasingDirection.Out
11
12keyframe:AddPose(pose) -- pose.Parent = keyframe
13
14task.wait(2)
15
16keyframe:RemovePose(pose) -- pose.Parent = nil
17
18task.wait(2)
19
20keyframe:AddPose(pose) -- pose.Parent = keyframe
21
22task.wait(2)
23
24pose:AddSubPose(pose2) -- pose2.Parent = pose
25
26task.wait(2)
27
28pose:RemoveSubPose(pose2) -- pose2.Parent = nil

GetSubPoses

Returns an array containing all sub Poses that have been added to a Pose. This is functionally the same as using the Instance:GetChildren() function on the Pose.

Note: this function returns all children of the Pose, including non Pose Instances if any are present.


Returns

An array of sub Poses.

Code Samples

Keyframe Reset Poses

1local function resetPoses(parent)
2 -- both functions are equivalent to GetChildren
3 local poses = parent:IsA("Keyframe") and parent:GetPoses() or parent:IsA("Pose") and parent:GetSubPoses()
4
5 for _, pose in pairs(poses) do
6 if pose:IsA("Pose") then
7 pose.CFrame = CFrame.new()
8 -- recurse
9 resetPoses(pose)
10 end
11 end
12end

RemoveSubPose

void

Removes a sub Pose from the Pose by parenting it to nil. This is functionally identical to setting the new pose's Instance.Parent to nil.

Note: If an Instance other than Pose is used as a Pose parameter, this function removes that Instance and does not provide an error.

Parameters

pose: Instance

The Pose to be removed.


Returns

void

Code Samples

Keyframe Add/Remove Pose

1local keyframe = Instance.new("Keyframe")
2keyframe.Parent = workspace
3
4local pose = Instance.new("Pose")
5pose.EasingStyle = Enum.PoseEasingStyle.Cubic
6pose.EasingDirection = Enum.PoseEasingDirection.Out
7
8local pose2 = Instance.new("Pose")
9pose2.EasingStyle = Enum.PoseEasingStyle.Cubic
10pose2.EasingDirection = Enum.PoseEasingDirection.Out
11
12keyframe:AddPose(pose) -- pose.Parent = keyframe
13
14task.wait(2)
15
16keyframe:RemovePose(pose) -- pose.Parent = nil
17
18task.wait(2)
19
20keyframe:AddPose(pose) -- pose.Parent = keyframe
21
22task.wait(2)
23
24pose:AddSubPose(pose2) -- pose2.Parent = pose
25
26task.wait(2)
27
28pose:RemoveSubPose(pose2) -- pose2.Parent = nil