Animation Node Definition
*เนื้อหานี้แปลโดยใช้ AI (เวอร์ชัน Beta) และอาจมีข้อผิดพลาด หากต้องการดูหน้านี้เป็นภาษาอังกฤษ ให้คลิกที่นี่
ข้อมูลสรุป
คุณสมบัติ
วิธีการ
AddInputPin(pin: string):() |
RemoveInputPin(pin: string):() |
SetOrderedInputPinNames(pins: {any}):() |
เหตุการณ์
ตัวอย่างโค้ด
เชื่อมคลิปกับโหนดผสม
local HttpService = game:GetService("HttpService")
local WALK_ANIMATION_ID = "rbxassetid://2510202577"
local RUN_ANIMATION_ID = "rbxassetid://2510198475"
local graph = Instance.new("AnimationGraphDefinition")
graph.Name = "WalkRunGraph"
local function createNode(name: string, nodeType: Enum.AnimationNodeType): AnimationNodeDefinition
local node = Instance.new("AnimationNodeDefinition")
node.Name = name
node.NodeId = HttpService:GenerateGUID(false)
-- ตั้งค่าประเภทก่อน เนื่องจากการเปลี่ยนแปลงจะรีเซ็ต
-- รายการพินนำเข้า
node.NodeType = nodeType
node.Parent = graph
return node
end
local function connect(inputNode: AnimationNodeDefinition, pinName: string, sourceNode: AnimationNodeDefinition): ObjectValue
local connection = Instance.new("ObjectValue")
connection.Name = pinName
connection.Value = sourceNode
connection.Parent = inputNode
return connection
end
local output = createNode("GraphOutput", Enum.AnimationNodeType.GraphOutput)
local blend = createNode("Blend1D", Enum.AnimationNodeType.Blend1DNode)
local walk = createNode("Walk", Enum.AnimationNodeType.ClipNode)
local run = createNode("Run", Enum.AnimationNodeType.ClipNode)
walk:SetAttribute("AnimationId", WALK_ANIMATION_ID)
run:SetAttribute("AnimationId", RUN_ANIMATION_ID)
-- ครึ่งทางระหว่างพินนำเข้าการเดินที่ 0 และพินนำเข้าการวิ่งที่ 1
blend:SetAttribute("Position", 0.5)
-- GraphOutput มีพิน "Pose" อยู่แล้ว
connect(output, "Pose", blend)
-- Blend1D เริ่มต้นด้วยไม่มีพิน ดังนั้นลงทะเบียนหนึ่งสำหรับการเชื่อมต่อแต่ละรายการ
connect(blend, "Walk", walk):SetAttribute("Position", 0)
blend:AddInputPin("Walk")
connect(blend, "Run", run):SetAttribute("Position", 1)
blend:AddInputPin("Run")
print(blend:GetOrderedInputPinNames()) -- {"Walk", "Run"}
graph.Parent = workspaceเอกสารอ้างอิงเกี่ยวกับ API
คุณสมบัติ
วิธีการ
Add Input Pin
พารามิเตอร์
ส่งค่ากลับ
()
ตัวอย่างโค้ด
เชื่อมคลิปกับโหนดผสม
local HttpService = game:GetService("HttpService")
local WALK_ANIMATION_ID = "rbxassetid://2510202577"
local RUN_ANIMATION_ID = "rbxassetid://2510198475"
local graph = Instance.new("AnimationGraphDefinition")
graph.Name = "WalkRunGraph"
local function createNode(name: string, nodeType: Enum.AnimationNodeType): AnimationNodeDefinition
local node = Instance.new("AnimationNodeDefinition")
node.Name = name
node.NodeId = HttpService:GenerateGUID(false)
-- ตั้งค่าประเภทก่อน เนื่องจากการเปลี่ยนแปลงจะรีเซ็ต
-- รายการพินนำเข้า
node.NodeType = nodeType
node.Parent = graph
return node
end
local function connect(inputNode: AnimationNodeDefinition, pinName: string, sourceNode: AnimationNodeDefinition): ObjectValue
local connection = Instance.new("ObjectValue")
connection.Name = pinName
connection.Value = sourceNode
connection.Parent = inputNode
return connection
end
local output = createNode("GraphOutput", Enum.AnimationNodeType.GraphOutput)
local blend = createNode("Blend1D", Enum.AnimationNodeType.Blend1DNode)
local walk = createNode("Walk", Enum.AnimationNodeType.ClipNode)
local run = createNode("Run", Enum.AnimationNodeType.ClipNode)
walk:SetAttribute("AnimationId", WALK_ANIMATION_ID)
run:SetAttribute("AnimationId", RUN_ANIMATION_ID)
-- ครึ่งทางระหว่างพินนำเข้าการเดินที่ 0 และพินนำเข้าการวิ่งที่ 1
blend:SetAttribute("Position", 0.5)
-- GraphOutput มีพิน "Pose" อยู่แล้ว
connect(output, "Pose", blend)
-- Blend1D เริ่มต้นด้วยไม่มีพิน ดังนั้นลงทะเบียนหนึ่งสำหรับการเชื่อมต่อแต่ละรายการ
connect(blend, "Walk", walk):SetAttribute("Position", 0)
blend:AddInputPin("Walk")
connect(blend, "Run", run):SetAttribute("Position", 1)
blend:AddInputPin("Run")
print(blend:GetOrderedInputPinNames()) -- {"Walk", "Run"}
graph.Parent = workspaceRemove Input Pin
เหตุการณ์