Pose

Hiển Thị Bản Đã Lỗi Thời

*Nội dung này được dịch bằng AI (Beta) và có thể có lỗi. Để xem trang này bằng tiếng Anh, hãy nhấp vào đây.

Một tư thế giữ CFrame được áp dụng cho Motor6D được kết nối với BasePart liên quan của nó.Phần được kiểm soát phụ thuộc vào tên của Tư thế.

Các tư thế là khối xây dựng cơ bản của các hoạt hình và, với Keyframes, tạo ra KeyframeSequences .

Tư thế, khớp và cấu trúc

Mặc dù một tư thế được gán cho một BasePart bằng tên, đối tượng được xử lý trong lúc phát lại hoạt hình thực sự là Motor6D được kết nối với phần này.Các cành khung hoạt hình nhánh từ phần gốc của mô hình thông qua các khớp như vậy.

Trong một nhân vật R15, phần gốc là HumanoidRootPart.Phần thân thấp hơn được kết nối với HumanoidRootPart bởi một động cơ có tên là 'Root'.Do đó, CFrame của một tư thế có tên là 'LowerTorso' trong Keyframe sẽ được áp dụng cho động cơ có tên là 'Root', chứ không phải là chính Pose LowerTorso.

Các tư thế được sắp xếp theo một Keyframe dựa trên cấu trúc chung.Điều này có nghĩa là, Pose's CFrame được áp dụng cho động cơ kết nối phần liên quan đến tư thế với phần liên quan đến cha của tư thế.Xem dưới đây để có ví dụ hình ảnh về cấu trúc của các tư thế trên nhân vật R15.

Hoá thân CFrame

Hệ thống hoạt hình Roblox áp dụng Pose.CFrame cho tương ứng Motor6D bằng cách thao tác biến đổi tương đối của động cơ, thuộc tính Motor6D.Transform.Các giá trị gốc C0C1 không thay đổi.

Mẫu mã

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

Tóm Tắt

Thuộc Tính

Thuộc Tính kế thừa từ PoseBase

Phương Pháp

Thuộc Tính

CFrame

Đọc Song Song

Cái này CFrame áp dụng cho Motor6D tương ứng với Pose khi Motor6D.Transform được thay đổi.Các giá trị gốc Motor6D.C0Motor6D.C1 không thay đổi.

Pose các đối tượng được sắp xếp theo một Keyframe cấp bậc chung.Điều này có nghĩa là, Pose.CFrame được áp dụng cho động cơ kết nối phần liên quan đến tư thế với phần liên quan đến cha của tư thế.

Phương Pháp

AddSubPose

()

Thêm một sub Pose vào Pose bằng cách nuôi nó. Nó có chức năng tương tự như việc đặt Instance.Parent mới của tư thế vào tư thế.

Lưu ý, chức năng này sẽ không xảy ra lỗi khi một ví dụ khác ngoài Pose được cung cấp làm tham số tư thế và sẽ nuôi nó thành công.

Tham Số

pose: Instance

Các Pose được thêm vào.

Giá Trị Mặc Định: ""

Lợi Nhuận

()

Mẫu mã

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

Trả về một array chứa tất cả các sub Poses đã được thêm vào một Pose .Đây là chức năng tương tự như sử dụng chức năng Instance:GetChildren() trên Pose.

Lưu ý: chức năng này trả lại tất cả các con của Pose , bao gồm cả những con không có Class.Pose``Class.Instance|Instances nếu có bất kỳ hiện diện.


Lợi Nhuận

Instances

Một mảng của sub Poses .

Mẫu mã

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

()

Loại bỏ một sub Pose từ Pose bằng cách nuôi nó thành nil .Điều này tương tự về chức năng với việc đặt Instance.Parent mới vị trí nil .

Lưu ý: Nếu một Instance khác ngoài Pose được sử dụng như một tham số Pose, chức năng này sẽ xóa điều đó Instance và không cung cấp lỗi.

Tham Số

pose: Instance

Các Pose để được xóa bỏ.

Giá Trị Mặc Định: ""

Lợi Nhuận

()

Mẫu mã

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

Sự Kiện