Keyframe
*このコンテンツは、ベータ版のAI(人工知能)を使用して翻訳されており、エラーが含まれている可能性があります。このページを英語で表示するには、 こちら をクリックしてください。
キーフレームには、Poses を適用したジョイントに Model で指定された時間により持続します。Keyframes は、アニメーションプレイバック中にインターポールされます。
注意、ほとんどの場合、アニメーションエディタはアニメーション機能のほとんどをカバーするため、開発者は KeyframeSequences を操作する必要はありません。ただし、一部の場合、開発者は Script からアニメーションを生成するか、自分のプラグインを構築する必要があります。
構造
キーフレームは KeyframeSequence 内にあり、 Class.Pose オブジェクトを含みます。ポーズは、ジョイント ヘリテージの観点から名前付けされており、 Class.BasePart|BaseParts に対
注、Poses は、BaseParts に対応する、アニメーションが正しく再生するために、パーツ名を明確にする必要があります。
インタープレーション
アニメーションの再生中、異なるキーフレームのポーズは間接的に接続されます。これにより、フレームを定義する必要なくスムーズなアニメーションを作成できます。注、キーフレームオブジェクトは、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.
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)
概要
プロパティ
アニメーションの Class.Keyframe の位置 (秒単位) です。これは、キーフレーム内の Keyframe が表示される時間を決定します。
方法
親クラスになって KeyframeMarker を Keyframe に追加する。
Class.Keyframe に追加されたすべての Keyframe を含むアレイを返します。
Class.Pose|Poses が含まれるすべてのアレイを返します。Keyframe に追加されたすべての Class.Pose|Poses が含まれます。
設定の Class.Keyframe を無効にすると、Keyframe の子として、Instance.Parent を nil に設定します。
Class.Pose を Keyframe に設定して、Instance.Parent を nil に設定して、1>Class.Pose1> を削除します。
プロパティ
Time
このプロパティは、アニメーションで Keyframe の時間ポジション (in seconds) を提供します。これにより、キーフレーム内の Poses が表示される時間が決まります。
Class.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.
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 をキーフレームに設定する機能は、マーカーの 2>Class.Instance.Parent2> をキーフレームに設定すると機能的に同等です。
注: この関数は、[キーフレームマーカー] 以外のインスタンスがパラメータとして与えられた場合でもエラーしないで、親として成功します。
キーフレームについてもっと
Keyframe 名前はユニークでなくてもよい。たとえ、アニメーションが「パーティクル」という 3つのキーフレームを持つ場合、AnimationTrack:GetMarkerReachedSignal() によって接続されたイベントが毎回これらのキーフレームの 1つが達成されると、そのキーフレームの名前を変更する必要がありません。
Keyframe 名前は、アニメーションを作成または編集するときに Roblox アニメーションエディタに設定できます。ただし、既存のアニメーションをプレイする前に Script によって設定されることはできません。
参照してください:
パラメータ
戻り値
コードサンプル
This example demonstrates the Keyframe:AddMarker() and Keyframe:RemoveMarker() functions. Note these are functionally equivalent to parenting and un-parenting the markers.
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
この関数は、Poseをキーフレームに親化することで、Keyframeに追加します。これは、ポーズのInstance.Parentをキーフレームに設定するのと機能的に同等です。
注: この関数は、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.
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.
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
この関数は、<a href="/reference/engine/databases/databases.md">データベース</a> に追加されたすべての <a href="/reference/engine/databases/databases.md">Class.KeyframeMarker|KeyframeMarkers</a> を含むアレイを返します。注意、この関数は、<a href="/reference/engine/databases/databases.md">キーフレームマーカー</a> のみを返します。
キーフレームについてもっと
Keyframe 名前はユニークでなくてもよい。たとえ、アニメーションが「パーティクル」という 3つのキーフレームを持つ場合、AnimationTrack:GetMarkerReachedSignal() によって接続されたイベントが毎回これらのキーフレームの 1つが達成されると、そのキーフレームの名前を変更する必要がありません。
Keyframe 名前は、アニメーションを作成または編集するときに Roblox アニメーションエディタに設定できます。ただし、既存のアニメーションをプレイする前に Script によって設定されることはできません。
参照してください:
戻り値
Class.Keyframe に追加されたすべての Keyframe を含むアレイ。
コードサンプル
This example demonstrates the Keyframe:AddMarker() and Keyframe:GetMarkers() functions. After adding two markers, marker1 and marker2 to the keyframe, this example gets and prints the names of the added markers.
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
この関数は、Poses が Class.Keyframe に追加されたすべてのアレイを返します。
戻り値
Class.Pose|Poses の配列。
コードサンプル
This code sample includes a function to reset the CFrame of the Poses in a Keyframe.
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.Parent に捕まえます。
キーフレームマーカーの Instance.Parent は、Class.Instance の親に設定されますが、破壊されません。これは、マーカーが参照されると、後で親になり直すことができることを意味します。
注: この関数は、キーフレームマーカー以外のインスタンスがパラメータとして与えられた場合でもエラーしません。
キーフレームについてもっと
Keyframe 名前はユニークでなくてもよい。たとえ、アニメーションが「パーティクル」という 3つのキーフレームを持つ場合、AnimationTrack:GetMarkerReachedSignal() によって接続されたイベントが毎回これらのキーフレームの 1つが達成されると、そのキーフレームの名前を変更する必要がありません。
Keyframe 名前は、アニメーションを作成または編集するときに Roblox アニメーションエディタに設定できます。ただし、既存のアニメーションをプレイする前に Script によって設定されることはできません。
参照してください:
パラメータ
戻り値
コードサンプル
This example demonstrates the Keyframe:AddMarker() and Keyframe:RemoveMarker() functions. Note these are functionally equivalent to parenting and un-parenting the markers.
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
この関数は、Pose を Keyframe に設定して、Instance.Parent を 2>nil2> に無損に設定して、ポーズを参照していることを意味します。これは、提供されたポーズが参照され、後で 5>nil5> に再親化できることを意味します。
注: この関数は、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.
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