Keyframe

사용되지 않는 항목 표시

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

키 프레임은 애니메이션의 특정 시점에 적용된 조인트에 적용된 키를 보관합니다.Keyframes 는 애니메이션 재생 중에 간격을 두고 삽입됩니다.

대부분의 경우 개발자는 애니메이션 편집기가 대부분의 애니메이션 기능을 다루기 때문에 KeyframeSequences를 조작할 필요가 없습니다.그러나 경우에 따라 개발자는 Script 에서 애니메이션을 생성하거나 자체 플러그인을 빌드하길 원할 수 있습니다.

구조

키 프레임은 내에서 유지되며 개체를 포함합니다.포즈는 해당하는 BaseParts 에 따라 이름이 지정되고 공동 계층 구조 측면에서 구조화됩니다.즉, 각 Pose 는 부착된 부품에 해당하는 Pose 에 부모가 됩니다.

참고, as 는 그에 따라 명명되므로, 애니메이션은 올바르게 재생하려면 고유한 부품 이름을 사용해야 합니다.

간섭

애니메이션 재생 중에 다른 키 프레임의 포즈가 중간에 인터폴레이션됩니다.이렇게 하면 모든 프레임을 정의할 필요 없이 원활한 애니메이션을 만들 수 있습니다.주의, 간섭 스타일은 Pose 개체에서 결정됩니다.키프레임 개체는 단순히 애니메이션의 정의된 시점에서 Poses 만 보유합니다(Keyframe.Time).

코드 샘플

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)

요약

속성

  • 병렬 읽기

    애니메이션의 Keyframe 시간 위치(초)입니다. 이것은 키프레임 내부에 표시될 시간을 결정합니다. Poses

메서드

속성

Time

병렬 읽기

이 속성은 애니메이션에서 Keyframe 시간 위치(초)를 제공합니다.이로써 키프레임 내부에서 Poses 가 표시되는 시간이 결정됩니다.

애니메이션의 길이를 결정하기 위해 Keyframe 에서 가장 높은 시간 값을 가진 KeyframeSequence 가 사용됩니다.

코드 샘플

This sample contains a simple function that will get the length of a KeyframeSequence by finding the Keyframe with the highest Keyframe.Time value.

Get KeyframeSequence Length

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

()

이 함수는 키프레임에 부모로 지정하여 KeyframeMarker 를 추가하고 Keyframe 에 키프레임을 추가합니다.마커의 Instance.Parent를 키프레임으로 설정하는 것과 기능적으로 동일합니다.

주의, 키프레임마커가 아닌 인스턴스가 매개 변수로 제공되면 이 함수에서 오류가 발생하지 않으며 성공적으로 부모가 됩니다.

키프레임에 대해 더 알아보기

Keyframe 이름은 유일해야 하지 않습니다.예를 들어, 애니메이션에 "파편"이라는 세 개의 키프레임이 있고 연결된 이벤트가 AnimationTrack:GetMarkerReachedSignal()에 도달할 때마다 발생하면 연결된 이벤트는 이 키프레임 중 하나가 도달할 때마다 발생합니다.

Keyframe 이름은 애니메이션을 만들거나 편집할 때 Roblox 애니메이션 편집기에서 설정할 수 있습니다.그러나 플레이하기 전에 기존 애니메이션에서 Script에 의해 설정될 수 없습니다.

참조하세요:

매개 변수

marker: Instance

부모로 지정된 KeyframeMarkerKeyframe 에 전달됩니다.

기본값: ""

반환

()

코드 샘플

이 예제에서는 Keyframe:AddMarker()Keyframe:RemoveMarker() 함수를 보여줍니다.이들은 기능적으로 parenting 과 동일하며 마커를 부모에서 제거합니다.

마커 추가/마커 제거

local keyframe = Instance.new("Keyframe")
keyframe.Parent = workspace
local marker = Instance.new("KeyframeMarker")
marker.Name = "FootStep"
marker.Value = 100
keyframe:AddMarker(marker) --마커.Parent = 키 프레임
task.wait(2)
keyframe:RemoveMarker(marker) --marker.Parent = nil

AddPose

()

이 함수는 키프레임에 부모로 지정하여 Pose 를 추가하고 Keyframe 에 키프레임을 추가합니다.포즈의 Instance.Parent를 키 프레임으로 설정하는 것과 기능적으로 동일합니다.

참고, 이 함수는 포즈 매개변수로 다른 인스턴스가 주어질 때 오류가 발생하지 않으며 성공적으로 부모가 됩니다.

매개 변수

pose: Instance

추가될 Pose 가 있습니다.

기본값: ""

반환

()

코드 샘플

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 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

GetMarkers

Instances

이 함수는 를 모두 포함하는 배열을 반환하여 에 추가된 모든 을 반환합니다.이 함수는 KeyframeMarker 유형의 instances만 반환합니다.

키프레임에 대해 더 알아보기

Keyframe 이름은 유일해야 하지 않습니다.예를 들어, 애니메이션에 "파편"이라는 세 개의 키프레임이 있고 연결된 이벤트가 AnimationTrack:GetMarkerReachedSignal()에 도달할 때마다 발생하면 연결된 이벤트는 이 키프레임 중 하나가 도달할 때마다 발생합니다.

Keyframe 이름은 애니메이션을 만들거나 편집할 때 Roblox 애니메이션 편집기에서 설정할 수 있습니다.그러나 플레이하기 전에 기존 애니메이션에서 Script에 의해 설정될 수 없습니다.

참조하세요:


반환

Instances

에 추가된 모든 배열 을 포함하는 배열.

코드 샘플

이 예제에서는 Keyframe:AddMarker()Keyframe:GetMarkers() 함수를 보여줍니다.키 프레임에 두 개의 마커를 추가한 후 marker1marker2 을 마커에 추가하면 이 예제에서 추가된 마커의 이름을 가져와 인쇄합니다.

키프레임에 연결된 키프레임 마커 가져오기

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) --마커.Parent = 키 프레임
keyframe:AddMarker(marker2) --마커.Parent = 키 프레임
local markers = keyframe:GetMarkers()
for _, marker in pairs(markers) do
print(marker.Name)
end

GetPoses

Instances

이 함수는 추가된 모든 Poses를 포함하는 배열을 반환하며, 이는 Keyframe에 추가되었습니다.


반환

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

RemoveMarker

()

이 함수는 설정을 통해 KeyframeMarker 에서 Keyframe 를 제거하여 Instance.Parentnil 으로 변경합니다.

키프레임 마커의 Instance.Parentnil 로 설정되지만 파괴되지 않습니다.즉, 표시자가 참조되면 나중에 다시 부모로 지정될 수 있습니다.

주의, 키프레임마커가 아닌 인스턴스가 매개 변수로 제공되면 이 함수에 오류가 발생하지 않습니다.

키프레임에 대해 더 알아보기

Keyframe 이름은 유일해야 하지 않습니다.예를 들어, 애니메이션에 "파편"이라는 세 개의 키프레임이 있고 연결된 이벤트가 AnimationTrack:GetMarkerReachedSignal()에 도달할 때마다 발생하면 연결된 이벤트는 이 키프레임 중 하나가 도달할 때마다 발생합니다.

Keyframe 이름은 애니메이션을 만들거나 편집할 때 Roblox 애니메이션 편집기에서 설정할 수 있습니다.그러나 플레이하기 전에 기존 애니메이션에서 Script에 의해 설정될 수 없습니다.

참조하세요:

매개 변수

marker: Instance

마커가 Keyframe 제거되고 있습니다.

기본값: ""

반환

()

코드 샘플

이 예제에서는 Keyframe:AddMarker()Keyframe:RemoveMarker() 함수를 보여줍니다.이들은 기능적으로 parenting 과 동일하며 마커를 부모에서 제거합니다.

마커 추가/마커 제거

local keyframe = Instance.new("Keyframe")
keyframe.Parent = workspace
local marker = Instance.new("KeyframeMarker")
marker.Name = "FootStep"
marker.Value = 100
keyframe:AddMarker(marker) --마커.Parent = 키 프레임
task.wait(2)
keyframe:RemoveMarker(marker) --marker.Parent = nil

RemovePose

()

이 함수는 설정을 통해 Pose 에서 Keyframe 를 제거하여 그것을 파괴하지 않고 Instance.Parentnil 으로 설정하여 제거합니다.즉, 제공된 포즈가 참조되어 나중에 다시 부모로 지정될 수 있음을 의미합니다.

참고, 이 함수는 포즈 매개변수로 다른 인스턴스가 주어질 때 오류가 발생하지 않습니다. Pose

매개 변수

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

이벤트