Pose

顯示已棄用項目

*此內容是使用 AI(Beta 測試版)翻譯,可能含有錯誤。若要以英文檢視此頁面,請按一下這裡

一個姿勢會保持 CFrame 適用於連接到其相關 Motor6DBasePart 。被控制的部分取決於姿勢的名稱。

姿勢是動畫的基本磚塊,並且使用 Keyframes 組成 KeyframeSequences

姿勢、關節和階層

雖然姿勢會被指派給 BasePart 以名稱,但在動畫播放期間操作的對象實際上是連接到此部分的 Motor6D 。動畫骨架從模型的根部通過這些聯節分支出去。

在 R15 角色骨架中,根部分是人形根部分。下半身連接到人形根部的零件名為「根」的馬達。因此,一個名為「LowerTorso」的姿勢的 CFrameKeyframe 中將應用於名為「根」的馬達,而不是姿勢本身。

位置是根據共同層級在 Keyframe 中排列的。這意味著,姿勢的 CFrame 被應用到連接姿勢相關零件到姿勢相關零件的電機上。請參見下方的視覺示例來了解 R15 角色上的姿勢結構。

擺姿勢 CFrame

Roblox 動畫系統會將 Pose.CFrame 應用於相應的 Motor6D ,通過操縱引擎的相對轉換、Motor6D.Transform 屬性來實現。原始 C0C1 值不會變更。

範例程式碼

This sample includes a function that will generate a 'blank' keyframe containing blank poses for all of the model's connected parts in the correct hierarchical order.

Keyframe Generate Poses

local function generateKeyframe(model)
if not model.PrimaryPart then
warn("No primary part set")
return
end
local rootPart = model.PrimaryPart:GetRootPart()
if not rootPart then
warn("Root part not found")
return
end
local partsAdded = {}
partsAdded[rootPart] = true
local function addPoses(part, parentPose)
-- get all of the joints attached to the part
for _, joint in pairs(part:GetJoints()) do
-- we're only interested in Motor6Ds
if joint:IsA("Motor6D") then
-- find the connected part
local connectedPart = nil
if joint.Part0 == part then
connectedPart = joint.Part1
elseif joint.Part1 == part then
connectedPart = joint.Part0
end
if connectedPart then
-- make sure we haven't already added this part
if not partsAdded[connectedPart] then
partsAdded[connectedPart] = true
-- create a pose
local pose = Instance.new("Pose")
pose.Name = connectedPart.Name
parentPose:AddSubPose(pose)
-- recurse
addPoses(connectedPart, pose)
end
end
end
end
end
local keyframe = Instance.new("Keyframe")
-- populate the keyframe
local rootPose = Instance.new("Pose")
rootPose.Name = rootPart.Name
addPoses(rootPart, rootPose)
keyframe:AddPose(rootPose)
return keyframe
end
local character = script.Parent
local keyframe = generateKeyframe(character)
print(keyframe)

This code sample includes a function to reset the CFrame of the Poses in a Keyframe.

Keyframe Reset Poses

local function resetPoses(parent)
-- both functions are equivalent to GetChildren
local poses = parent:IsA("Keyframe") and parent:GetPoses() or parent:IsA("Pose") and parent:GetSubPoses()
for _, pose in pairs(poses) do
if pose:IsA("Pose") then
pose.CFrame = CFrame.new()
-- recurse
resetPoses(pose)
end
end
end

概要

屬性

屬性 繼承自 PoseBase

方法

屬性

CFrame

平行讀取

CFrame 適用於當 Motor6DPose 相對應時,更改 Motor6D.Transform 時。原始 Motor6D.C0Motor6D.C1 值不會變更。

Pose 對象依據共同層級進行排列在 Keyframe 中。這意味著,Pose.CFrame 被應用到連接部件與姿勢相關的部件與姿勢的父元素部件的電機。

方法

AddSubPose

()

向 添加子 ,將它作為父親將其設置為新姿勢的 。它的功能與設置新姿勢的 相同。

注意,當給予模型參數以外的實例作為姿勢參數時,此功能不會發生錯誤,並且會成功地將其作為父級。

參數

pose: Instance

要添加的 Pose

預設值:""

返回

()

範例程式碼

This sample demonstrates quickly the Keyframe.AddPose, Keyframe.RemovePose and Pose.AddSubPose and Pose.RemoveSubPose functions. Note these are functionally equivalent to parenting and un-parenting the poses.

Keyframe Add/Remove Pose

local keyframe = Instance.new("Keyframe")
keyframe.Parent = workspace
local pose = Instance.new("Pose")
pose.EasingStyle = Enum.PoseEasingStyle.Cubic
pose.EasingDirection = Enum.PoseEasingDirection.Out
local pose2 = Instance.new("Pose")
pose2.EasingStyle = Enum.PoseEasingStyle.Cubic
pose2.EasingDirection = Enum.PoseEasingDirection.Out
keyframe:AddPose(pose) -- pose.Parent = keyframe
task.wait(2)
keyframe:RemovePose(pose) -- pose.Parent = nil
task.wait(2)
keyframe:AddPose(pose) -- pose.Parent = keyframe
task.wait(2)
pose:AddSubPose(pose2) -- pose2.Parent = pose
task.wait(2)
pose:RemoveSubPose(pose2) -- pose2.Parent = nil

GetSubPoses

Instances

返回包含所有子 Poses 已添加到 Pose 的一個 array。這與使用 Instance:GetChildren() 函數在 Pose 上功能相同。

注意:此功能返回 所有子孫,包括非 如果任何存在。


返回

Instances

一個子 Poses 陣列。

範例程式碼

This code sample includes a function to reset the CFrame of the Poses in a Keyframe.

Keyframe Reset Poses

local function resetPoses(parent)
-- both functions are equivalent to GetChildren
local poses = parent:IsA("Keyframe") and parent:GetPoses() or parent:IsA("Pose") and parent:GetSubPoses()
for _, pose in pairs(poses) do
if pose:IsA("Pose") then
pose.CFrame = CFrame.new()
-- recurse
resetPoses(pose)
end
end
end

RemoveSubPose

()

將子 PosePose 移除到 nil ,通過親子關係將它移除。這與設置新姿勢的 Instance.Parentnil 功能相同。

注意:如果使用不是 Instance Pose 的其他參數作為 Pose 參數,此函數將移除該 Instance 並不提供錯誤。

參數

pose: Instance

要移除的 Pose

預設值:""

返回

()

範例程式碼

This sample demonstrates quickly the Keyframe.AddPose, Keyframe.RemovePose and Pose.AddSubPose and Pose.RemoveSubPose functions. Note these are functionally equivalent to parenting and un-parenting the poses.

Keyframe Add/Remove Pose

local keyframe = Instance.new("Keyframe")
keyframe.Parent = workspace
local pose = Instance.new("Pose")
pose.EasingStyle = Enum.PoseEasingStyle.Cubic
pose.EasingDirection = Enum.PoseEasingDirection.Out
local pose2 = Instance.new("Pose")
pose2.EasingStyle = Enum.PoseEasingStyle.Cubic
pose2.EasingDirection = Enum.PoseEasingDirection.Out
keyframe:AddPose(pose) -- pose.Parent = keyframe
task.wait(2)
keyframe:RemovePose(pose) -- pose.Parent = nil
task.wait(2)
keyframe:AddPose(pose) -- pose.Parent = keyframe
task.wait(2)
pose:AddSubPose(pose2) -- pose2.Parent = pose
task.wait(2)
pose:RemoveSubPose(pose2) -- pose2.Parent = nil

活動