배우기
엔진 클래스
Keyframe

*이 콘텐츠는 AI(베타)를 사용해 번역되었으며, 오류가 있을 수 있습니다. 이 페이지를 영어로 보려면 여기를 클릭하세요.


요약
속성
상속된 멤버
코드 샘플
키프레임 생성 포즈
local function generateKeyframe(model)
if not model.PrimaryPart then
warn("주요 부품이 설정되지 않음")
return
end
local rootPart = model.PrimaryPart:GetRootPart()
if not rootPart then
warn("루트 부품을 찾을 수 없음")
return
end
local partsAdded = {}
partsAdded[rootPart] = true
local function addPoses(part, parentPose)
-- 부품에 연결된 모든 조인트를 가져옵니다.
for _, joint in pairs(part:GetJoints()) do
-- Motor6D에만 관심이 있습니다.
if joint:IsA("Motor6D") then
-- 연결된 부품을 찾습니다.
local connectedPart = nil
if joint.Part0 == part then
connectedPart = joint.Part1
elseif joint.Part1 == part then
connectedPart = joint.Part0
end
if connectedPart then
-- 이미 이 부품을 추가하지 않았는지 확인합니다.
if not partsAdded[connectedPart] then
partsAdded[connectedPart] = true
-- 포즈를 생성합니다.
local pose = Instance.new("Pose")
pose.Name = connectedPart.Name
parentPose:AddSubPose(pose)
-- 재귀 호출
addPoses(connectedPart, pose)
end
end
end
end
end
local keyframe = Instance.new("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)

API 참조
속성
Time
병렬 읽기
기능: Animation
Keyframe.Time:number
코드 샘플
키프레임 시퀀스 길이 가져오기
local function getSequenceLength(keyframeSequence)
local length = 0
for _, keyframe in pairs(keyframeSequence:GetKeyframes()) do
if keyframe.Time > length then
length = keyframe.Time
end
end
return length
end
local keyframeSequence = Instance.new("KeyframeSequence")
getSequenceLength(keyframeSequence)

메서드
AddMarker
기능: Animation
Keyframe:AddMarker(marker:Instance):()
매개 변수
marker:Instance
반환
()
코드 샘플
마커 추가/마커 제거
local keyframe = Instance.new("Keyframe")
keyframe.Parent = workspace
local marker = Instance.new("KeyframeMarker")
marker.Name = "FootStep"
marker.Value = 100
keyframe:AddMarker(marker) --marker.Parent = keyframe
task.wait(2)
keyframe:RemoveMarker(marker) --marker.Parent = nil

AddPose
기능: Animation
Keyframe:AddPose(pose:Instance):()
매개 변수
반환
()
코드 샘플
키프레임 생성 포즈
local function generateKeyframe(model)
if not model.PrimaryPart then
warn("주요 부품이 설정되지 않음")
return
end
local rootPart = model.PrimaryPart:GetRootPart()
if not rootPart then
warn("루트 부품을 찾을 수 없음")
return
end
local partsAdded = {}
partsAdded[rootPart] = true
local function addPoses(part, parentPose)
-- 부품에 연결된 모든 조인트를 가져옵니다.
for _, joint in pairs(part:GetJoints()) do
-- Motor6D에만 관심이 있습니다.
if joint:IsA("Motor6D") then
-- 연결된 부품을 찾습니다.
local connectedPart = nil
if joint.Part0 == part then
connectedPart = joint.Part1
elseif joint.Part1 == part then
connectedPart = joint.Part0
end
if connectedPart then
-- 이미 이 부품을 추가하지 않았는지 확인합니다.
if not partsAdded[connectedPart] then
partsAdded[connectedPart] = true
-- 포즈를 생성합니다.
local pose = Instance.new("Pose")
pose.Name = connectedPart.Name
parentPose:AddSubPose(pose)
-- 재귀 호출
addPoses(connectedPart, pose)
end
end
end
end
end
local keyframe = Instance.new("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)
키프레임 추가/제거 포즈
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

GetMarkers
기능: Animation
Keyframe:GetMarkers():{KeyframeMarker}
코드 샘플
키프레임에 연결된 키프레임 마커 가져오기
local keyframe = Instance.new("Keyframe")
keyframe.Parent = workspace
local marker1 = Instance.new("KeyframeMarker")
marker1.Name = "FootStep"
marker1.Value = 100
local marker2 = Instance.new("KeyframeMarker")
marker2.Name = "Wave"
marker2.Value = 100
keyframe:AddMarker(marker1) --marker.Parent = keyframe
keyframe:AddMarker(marker2) --marker.Parent = keyframe
local markers = keyframe:GetMarkers()
for _, marker in pairs(markers) do
print(marker.Name) -- 마커 이름 출력
end

GetPoses
기능: Animation
Keyframe:GetPoses():{Pose}
반환
코드 샘플
키프레임 초기화 포즈
local function resetPoses(parent)
-- 두 함수는 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()
-- 재귀 호출
resetPoses(pose)
end
end
end

RemoveMarker
기능: Animation
Keyframe:RemoveMarker(marker:Instance):()
매개 변수
marker:Instance
반환
()
코드 샘플
마커 추가/마커 제거
local keyframe = Instance.new("Keyframe")
keyframe.Parent = workspace
local marker = Instance.new("KeyframeMarker")
marker.Name = "FootStep"
marker.Value = 100
keyframe:AddMarker(marker) --marker.Parent = keyframe
task.wait(2)
keyframe:RemoveMarker(marker) --marker.Parent = nil

RemovePose
기능: Animation
Keyframe:RemovePose(pose:Instance):()
매개 변수
반환
()
코드 샘플
키프레임 추가/제거 포즈
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

©2026 Roblox Corporation. Roblox 및 Roblox 로고, 'Powering Imagination'은 미국 및 기타 국가 내 당사의 등록 및 미등록 상표입니다.