学ぶ
エンジンクラス
AnimationTrack
作成できません

*このコンテンツは、ベータ版のAI(人工知能)を使用して翻訳されており、エラーが含まれている可能性があります。このページを英語で表示するには、 こちら をクリックしてください。



APIリファレンス
プロパティ
Animation
読み取り専用
複製されていません
並列読み取り
機能: Animation
AnimationTrack.Animation:Animation
コードサンプル
新しいアニメーションを待機
local humanoid = script.Parent:WaitForChild("Humanoid")
local animator = humanoid:WaitForChild("Animator")
animator.AnimationPlayed:Connect(function(animationTrack)
local animationName = animationTrack.Animation.Name
print("アニメーション再生中 " .. animationName)
end)

IsPlaying
読み取り専用
複製されていません
並列読み取り
機能: Animation
シミュレーションへのアクセス
AnimationTrack.IsPlaying:boolean
コードサンプル
AnimationTrackが再生中
local function playOrAdjust(animationTrack, fadeTime, weight, speed)
if not animationTrack.IsPlaying then
animationTrack:Play(fadeTime, weight, speed)
else
animationTrack:AdjustSpeed(speed)
animationTrack:AdjustWeight(weight, fadeTime)
end
end
local animation = Instance.new("Animation")
animation.AnimationId = "rbxassetid://507765644"
local humanoid = script.Parent:WaitForChild("Humanoid")
local animator = humanoid:WaitForChild("Animator")
local animationTrack = animator:LoadAnimation(animation)
playOrAdjust(animationTrack, 1, 0.6, 1)

Length
読み取り専用
複製されていません
並列読み取り
機能: Animation
AnimationTrack.Length:number
コードサンプル
特定の期間にアニメーションを再生
local function playAnimationForDuration(animationTrack, duration)
local speed = animationTrack.Length / duration
animationTrack:Play()
animationTrack:AdjustSpeed(speed)
end
local animation = Instance.new("Animation")
animation.AnimationId = "rbxassetid://507765000"
local humanoid = script.Parent:WaitForChild("Humanoid")
local animator = humanoid:WaitForChild("Animator")
local animationTrack = animator:LoadAnimation(animation)
playAnimationForDuration(animationTrack, 3)

Looped
並列読み取り
機能: Animation
シミュレーションへのアクセス
AnimationTrack.Looped:boolean
コードサンプル
アニメーションループ
local Players = game:GetService("Players")
local localPlayer = Players.LocalPlayer
while not localPlayer.Character do
task.wait()
end
local character = localPlayer.Character
local humanoid = character:WaitForChild("Humanoid")
local animator = humanoid:WaitForChild("Animator")
local animation = Instance.new("Animation")
animation.AnimationId = "rbxassetid://507770453"
local animationTrack = animator:LoadAnimation(animation)
animationTrack.Looped = false
task.wait(3)
animationTrack:Play()
task.wait(4)
animationTrack.Looped = true
animationTrack:Play()
アニメーショントラックを指定されたループ数だけ再生する
local function playForNumberLoops(animationTrack, number)
animationTrack.Looped = true
animationTrack:Play()
local numberOfLoops = 0
local connection = nil
connection = animationTrack.DidLoop:Connect(function()
numberOfLoops = numberOfLoops + 1
print("ループ: ", numberOfLoops)
if numberOfLoops >= number then
animationTrack:Stop()
connection:Disconnect() -- 使用されなくなった接続は切断することが重要です
end
end)
end
local animation = Instance.new("Animation")
animation.AnimationId = "rbxassetid://507765644"
local humanoid = script.Parent:WaitForChild("Humanoid")
local animator = humanoid:WaitForChild("Animator")
local animationTrack = animator:LoadAnimation(animation)
playForNumberLoops(animationTrack, 5)

Priority
並列読み取り
機能: Animation
シミュレーションへのアクセス
AnimationTrack.Priority:Enum.AnimationPriority

Speed
読み取り専用
複製されていません
並列読み取り
機能: Animation
シミュレーションへのアクセス
AnimationTrack.Speed:number
コードサンプル
アニメーション速度
local ContentProvider = game:GetService("ContentProvider")
local Players = game:GetService("Players")
local localPlayer = Players.LocalPlayer
while not localPlayer.Character do
task.wait()
end
local character = localPlayer.Character
local humanoid = character:WaitForChild("Humanoid")
local animator = humanoid:WaitForChild("Animator")
local animation = Instance.new("Animation")
animation.AnimationId = "rbxassetid://507770453"
ContentProvider:PreloadAsync({ animation })
local animationTrack = animator:LoadAnimation(animation)
local normalSpeedTime = animationTrack.Length / animationTrack.Speed
animationTrack:AdjustSpeed(3)
local fastSpeedTime = animationTrack.Length / animationTrack.Speed
print("通常速度でアニメーションは", normalSpeedTime, "秒間再生されます")
print("3倍速でアニメーションは", fastSpeedTime, "秒間再生されます")
特定の期間にアニメーションを再生
local function playAnimationForDuration(animationTrack, duration)
local speed = animationTrack.Length / duration
animationTrack:Play()
animationTrack:AdjustSpeed(speed)
end
local animation = Instance.new("Animation")
animation.AnimationId = "rbxassetid://507765000"
local humanoid = script.Parent:WaitForChild("Humanoid")
local animator = humanoid:WaitForChild("Animator")
local animationTrack = animator:LoadAnimation(animation)
playAnimationForDuration(animationTrack, 3)

TimePosition
複製されていません
並列読み取り
機能: Animation
シミュレーションへのアクセス
AnimationTrack.TimePosition:number
コードサンプル
位置でアニメーションを凍結
function freezeAnimationAtTime(animationTrack, timePosition)
if not animationTrack.IsPlaying then
-- アニメーションが再生されていない場合、再生します
animationTrack:Play()
end
-- アニメーションを凍結するために速度を0に設定します
animationTrack:AdjustSpeed(0)
-- 希望のTimePositionにジャンプします
animationTrack.TimePosition = timePosition
end
function freezeAnimationAtPercent(animationTrack, percentagePosition)
if not animationTrack.IsPlaying then
-- アニメーションが再生されていない場合、再生します
animationTrack:Play()
end
-- アニメーションを凍結するために速度を0に設定します
animationTrack:AdjustSpeed(0)
-- 希望のTimePositionにジャンプします
animationTrack.TimePosition = (percentagePosition / 100) * animationTrack.Length
end
local animation = Instance.new("Animation")
animation.AnimationId = "rbxassetid://507765644"
local humanoid = script.Parent:WaitForChild("Humanoid")
local animator = humanoid:WaitForChild("Animator")
local animationTrack = animator:LoadAnimation(animation)
freezeAnimationAtTime(animationTrack, 0.5)
freezeAnimationAtPercent(animationTrack, 50)

WeightCurrent
読み取り専用
複製されていません
並列読み取り
機能: Animation
シミュレーションへのアクセス
AnimationTrack.WeightCurrent:number
コードサンプル
WeightCurrent と WeightTarget
local Players = game:GetService("Players")
local localPlayer = Players.LocalPlayer
while not localPlayer.Character do
task.wait()
end
local character = localPlayer.Character
local humanoid = character:WaitForChild("Humanoid")
local animator = humanoid:WaitForChild("Animator")
local animation1 = Instance.new("Animation")
animation1.AnimationId = "rbxassetid://507770453"
local animation2 = Instance.new("Animation")
animation2.AnimationId = "rbxassetid://507771019"
task.wait(3) -- キャラクターが配置されるまでの任意の待機時間
local animationTrack1 = animator:LoadAnimation(animation1)
local animationTrack2 = animator:LoadAnimation(animation2)
animationTrack1.Priority = Enum.AnimationPriority.Movement
animationTrack2.Priority = Enum.AnimationPriority.Action
animationTrack1:Play(0.1, 5, 1)
animationTrack2:Play(10, 3, 1)
local done = false
while not done and task.wait(0.1) do
if math.abs(animationTrack2.WeightCurrent - animationTrack2.WeightTarget) < 0.001 then
print("到達しました")
done = true
end
end

WeightTarget
読み取り専用
複製されていません
並列読み取り
機能: Animation
シミュレーションへのアクセス
AnimationTrack.WeightTarget:number
コードサンプル
WeightCurrent と WeightTarget
local Players = game:GetService("Players")
local localPlayer = Players.LocalPlayer
while not localPlayer.Character do
task.wait()
end
local character = localPlayer.Character
local humanoid = character:WaitForChild("Humanoid")
local animator = humanoid:WaitForChild("Animator")
local animation1 = Instance.new("Animation")
animation1.AnimationId = "rbxassetid://507770453"
local animation2 = Instance.new("Animation")
animation2.AnimationId = "rbxassetid://507771019"
task.wait(3) -- キャラクターが配置されるまでの任意の待機時間
local animationTrack1 = animator:LoadAnimation(animation1)
local animationTrack2 = animator:LoadAnimation(animation2)
animationTrack1.Priority = Enum.AnimationPriority.Movement
animationTrack2.Priority = Enum.AnimationPriority.Action
animationTrack1:Play(0.1, 5, 1)
animationTrack2:Play(10, 3, 1)
local done = false
while not done and task.wait(0.1) do
if math.abs(animationTrack2.WeightCurrent - animationTrack2.WeightTarget) < 0.001 then
print("到達しました")
done = true
end
end

方法
AdjustSpeed
機能: Animation
シミュレーションへのアクセス
AnimationTrack:AdjustSpeed(speed:number):()
パラメータ
speed:number
既定値: 1
戻り値
()
コードサンプル
特定の期間にアニメーションを再生
local function playAnimationForDuration(animationTrack, duration)
local speed = animationTrack.Length / duration
animationTrack:Play()
animationTrack:AdjustSpeed(speed)
end
local animation = Instance.new("Animation")
animation.AnimationId = "rbxassetid://507765000"
local humanoid = script.Parent:WaitForChild("Humanoid")
local animator = humanoid:WaitForChild("Animator")
local animationTrack = animator:LoadAnimation(animation)
playAnimationForDuration(animationTrack, 3)
アニメーション速度
local ContentProvider = game:GetService("ContentProvider")
local Players = game:GetService("Players")
local localPlayer = Players.LocalPlayer
while not localPlayer.Character do
task.wait()
end
local character = localPlayer.Character
local humanoid = character:WaitForChild("Humanoid")
local animator = humanoid:WaitForChild("Animator")
local animation = Instance.new("Animation")
animation.AnimationId = "rbxassetid://507770453"
ContentProvider:PreloadAsync({ animation })
local animationTrack = animator:LoadAnimation(animation)
local normalSpeedTime = animationTrack.Length / animationTrack.Speed
animationTrack:AdjustSpeed(3)
local fastSpeedTime = animationTrack.Length / animationTrack.Speed
print("通常速度でアニメーションは", normalSpeedTime, "秒間再生されます")
print("3倍速でアニメーションは", fastSpeedTime, "秒間再生されます")

AdjustWeight
機能: Animation
シミュレーションへのアクセス
AnimationTrack:AdjustWeight(
weight:number, fadeTime:number
):()
パラメータ
weight:number
既定値: 1
fadeTime:number
既定値: 0.100000001
戻り値
()
コードサンプル
アニメーション トラックの重みを変更
local function changeWeight(animationTrack, weight, fadeTime)
animationTrack:AdjustWeight(weight, fadeTime)
local startTime = tick()
while math.abs(animationTrack.WeightCurrent - weight) > 0.001 do
task.wait()
end
print("重みを変更するのにかかった時間 " .. tostring(tick() - startTime))
end
local animation = Instance.new("Animation")
animation.AnimationId = "rbxassetid://507765644"
local humanoid = script.Parent:WaitForChild("Humanoid")
local animator = humanoid:WaitForChild("Animator")
local animationTrack = animator:LoadAnimation(animation)
changeWeight(animationTrack, 0.6, 1)

GetMarkerReachedSignal
機能: Animation
AnimationTrack:GetMarkerReachedSignal(name:string):RBXScriptSignal
パラメータ
name:string
コードサンプル
キーフレームマーカーのリスニング
local Players = game:GetService("Players")
local player = Players.LocalPlayer
local character = player.Character or player.Character:Wait()
local humanoid = character:WaitForChild("Humanoid")
-- 新しい "Animation" インスタンスを作成
local kickAnimation = Instance.new("Animation")
-- その "AnimationId" を対応するアニメーションアセットIDに設定
kickAnimation.AnimationId = "rbxassetid://2515090838"
-- ヒューマノイドにアニメーションを読み込む
local kickAnimationTrack = humanoid:LoadAnimation(kickAnimation)
-- アニメーショントラックを再生
kickAnimationTrack:Play()
-- アニメーション用に名前付きイベントが定義されている場合、"GetMarkerReachedSignal()" に接続します
kickAnimationTrack:GetMarkerReachedSignal("KickEnd"):Connect(function(paramString)
print(paramString)
end)

GetParameter
機能: Animation
シミュレーションへのアクセス
AnimationTrack:GetParameter(key:string):Variant
パラメータ
key:string
戻り値
Variant

GetParameterDefaults
機能: Animation
AnimationTrack:GetParameterDefaults():Dictionary
戻り値

GetTargetInstance
機能: Animation
AnimationTrack:GetTargetInstance(name:string):Instance?
パラメータ
name:string
戻り値

GetTargetNames
機能: Animation
AnimationTrack:GetTargetNames():{any}
戻り値

GetTimeOfKeyframe
機能: Animation
AnimationTrack:GetTimeOfKeyframe(keyframeName:string):number
パラメータ
keyframeName:string
戻り値
コードサンプル
キーフレームにジャンプ
local function jumpToKeyframe(animationTrack, keyframeName)
local timePosition = animationTrack:GetTimeOfKeyframe(keyframeName)
if not animationTrack.IsPlaying then
animationTrack:Play()
end
animationTrack.TimePosition = timePosition
end
local ANIMATION_ID = 0
local KEYFRAME_NAME = "テスト"
local animation = Instance.new("Animation")
animation.AnimationId = "rbxassetid://" .. ANIMATION_ID
local humanoid = script.Parent:WaitForChild("Humanoid")
local animator = humanoid:WaitForChild("Animator")
local animationTrack = animator:LoadAnimation(animation)
jumpToKeyframe(animationTrack, KEYFRAME_NAME)

Play
機能: Animation
シミュレーションへのアクセス
AnimationTrack:Play(
fadeTime:number, weight:number, speed:number
):()
パラメータ
fadeTime:number
既定値: 0.100000001
weight:number
既定値: 1
speed:number
既定値: 1
戻り値
()
コードサンプル
特定の期間にアニメーションを再生
local function playAnimationForDuration(animationTrack, duration)
local speed = animationTrack.Length / duration
animationTrack:Play()
animationTrack:AdjustSpeed(speed)
end
local animation = Instance.new("Animation")
animation.AnimationId = "rbxassetid://507765000"
local humanoid = script.Parent:WaitForChild("Humanoid")
local animator = humanoid:WaitForChild("Animator")
local animationTrack = animator:LoadAnimation(animation)
playAnimationForDuration(animationTrack, 3)
位置でアニメーションを凍結
function freezeAnimationAtTime(animationTrack, timePosition)
if not animationTrack.IsPlaying then
-- アニメーションが再生されていない場合、再生します
animationTrack:Play()
end
-- アニメーションを凍結するために速度を0に設定します
animationTrack:AdjustSpeed(0)
-- 希望のTimePositionにジャンプします
animationTrack.TimePosition = timePosition
end
function freezeAnimationAtPercent(animationTrack, percentagePosition)
if not animationTrack.IsPlaying then
-- アニメーションが再生されていない場合、再生します
animationTrack:Play()
end
-- アニメーションを凍結するために速度を0に設定します
animationTrack:AdjustSpeed(0)
-- 希望のTimePositionにジャンプします
animationTrack.TimePosition = (percentagePosition / 100) * animationTrack.Length
end
local animation = Instance.new("Animation")
animation.AnimationId = "rbxassetid://507765644"
local humanoid = script.Parent:WaitForChild("Humanoid")
local animator = humanoid:WaitForChild("Animator")
local animationTrack = animator:LoadAnimation(animation)
freezeAnimationAtTime(animationTrack, 0.5)
freezeAnimationAtPercent(animationTrack, 50)

SetParameter
機能: Animation
シミュレーションへのアクセス
AnimationTrack:SetParameter(
key:string, value:Variant
):()
パラメータ
key:string
value:Variant
戻り値
()

SetTargetInstance
機能: Animation
AnimationTrack:SetTargetInstance(
name:string, target:Instance?
):()
パラメータ
name:string
target:Instance?
戻り値
()

Stop
機能: Animation
シミュレーションへのアクセス
AnimationTrack:Stop(fadeTime:number):()
パラメータ
fadeTime:number
既定値: 0.100000001
戻り値
()
コードサンプル
アニメーショントラック停止
local function fadeOut(animationTrack, fadeTime)
animationTrack:Stop(fadeTime)
local startTime = tick()
while animationTrack.WeightCurrent > 0 do
task.wait()
end
local timeTaken = tick() - startTime
print("ウェイトがリセットされるまでの時間: " .. tostring(timeTaken))
end
local animation = Instance.new("Animation")
animation.AnimationId = "rbxassetid://507765644"
local humanoid = script.Parent:WaitForChild("Humanoid")
local animator = humanoid:WaitForChild("Animator")
local animationTrack = animator:LoadAnimation(animation)
animationTrack:Play()
fadeOut(animationTrack, 1)

イベント
DidLoop
機能: Animation
AnimationTrack.DidLoop():RBXScriptSignal
コードサンプル
アニメーショントラックを指定されたループ数だけ再生する
local function playForNumberLoops(animationTrack, number)
animationTrack.Looped = true
animationTrack:Play()
local numberOfLoops = 0
local connection = nil
connection = animationTrack.DidLoop:Connect(function()
numberOfLoops = numberOfLoops + 1
print("ループ: ", numberOfLoops)
if numberOfLoops >= number then
animationTrack:Stop()
connection:Disconnect() -- 使用されなくなった接続は切断することが重要です
end
end)
end
local animation = Instance.new("Animation")
animation.AnimationId = "rbxassetid://507765644"
local humanoid = script.Parent:WaitForChild("Humanoid")
local animator = humanoid:WaitForChild("Animator")
local animationTrack = animator:LoadAnimation(animation)
playForNumberLoops(animationTrack, 5)

Ended
機能: Animation
AnimationTrack.Ended():RBXScriptSignal
コードサンプル
アニメーショントラックの終了
local InsertService = game:GetService("InsertService")
local Players = game:GetService("Players")
-- NPCモデルを作成してアニメーションを行います。
local npcModel = Players:CreateHumanoidModelFromUserIdAsync(129687796)
npcModel.Name = "JoeNPC"
npcModel.Parent = workspace
npcModel:MoveTo(Vector3.new(0, 15, 4))
local humanoid = npcModel:WaitForChild("Humanoid")
-- アニメーションをロードします。
local animationModel = InsertService:LoadAsset(2510238627)
local animation = animationModel:FindFirstChildWhichIsA("Animation", true)
local animator = humanoid:WaitForChild("Animator")
local animationTrack = animator:LoadAnimation(animation)
-- Stoppedイベントに接続します。これはアニメーションが自動的に停止したときや
-- 明示的にStopを呼び出したときに発火します。
animationTrack.Stopped:Connect(function()
print("アニメーションが停止しました")
end)
-- Endedイベントに接続します。これはアニメーションが完全に
-- 世界に影響を与えたときに発火します。この場合、animationTrack:Stopを呼び出して3秒後に
-- 発火します。3秒のフェードアウトを渡すからです。
animationTrack.Ended:Connect(function()
print("アニメーションが終了しました")
animationTrack:Destroy()
end)
-- 実行し、しばらく再生した後に停止します。
print("再生を呼び出します")
animationTrack:Play()
task.wait(10)
print("停止を呼び出します")
animationTrack:Stop(3)

KeyframeReached
非推奨

Stopped
機能: Animation
AnimationTrack.Stopped():RBXScriptSignal
コードサンプル
アニメーショントラック停止
local function yieldPlayAnimation(animationTrack, fadeTime, weight, speed)
animationTrack:Play(fadeTime, weight, speed)
animationTrack.Stopped:Wait()
print("アニメーションが停止しました")
end
local animation = Instance.new("Animation")
animation.AnimationId = "rbxassetid://507765644"
local humanoid = script.Parent:WaitForChild("Humanoid")
local animator = humanoid:WaitForChild("Animator")
local animationTrack = animator:LoadAnimation(animation)
yieldPlayAnimation(animationTrack, 1, 0.6, 1)

©2026 Roblox Corporation。Roblox(ロブロックス)、RobloxロゴおよびPowering Imaginationは、米国並びにその他の国における登録商標および非登録商標です。