mcpField
R
roblox-animations

roblox-animations

github.com/sentinelcore開発29920 回インストール35 週間前に更新
リポジトリ

roblox-animations について

roblox-animationsは、Robloxでアニメーション再生を実装する開発者向けのリファレンススキルです。トラックの読み込みや制御、ブレンド優先度、キャラクターとサーバー管理モデルに適したスクリプト配置を扱います。

主な機能

  1. 01Animator経由でアニメーションを読み込み
  2. 02トラック再生とイベントを制御
  3. 03ループ、優先度、ブレンドウェイトを設定
  4. 04HumanoidとAnimationControllerのリグに対応
  5. 05標準キャラクターアニメーションIDを置換

活用シーン

  1. 01ローカルプレイヤーキャラクターで再生
  2. 02NPCやサーバー管理モデルをアニメーション化
  3. 03待機、移動、アクショントラックをブレンド

インストール

コマンドをコピーしてターミナルで実行します。

$npx skills add https://github.com/sentinelcore/roblox-skills --skill roblox-animations

インストール後、Claude Code で/roblox-animationsを入力して読み込まれたか確認します。

詳細

Roblox アニメーションリファレンス

コアオブジェクト

オブジェクト目的
Animationアセット参照 — AnimationId を保持します
AnimatorHumanoid または AnimationController の内部に存在し、トラックを読み込んで駆動します
AnimationControllerキャラクター以外のリグで Humanoid の代わりになります
AnimationTrackLoadAnimation から返され、再生を制御します

アニメーションコードを実行する場所

シナリオスクリプトの種類場所
ローカルプレイヤーキャラクターLocalScriptStarterCharacterScripts
NPC / サーバー所有のモデルScriptモデル内部または ServerScriptService

プレイヤーキャラクターのアニメーションを Script から再生しないでください — ローカルクライアントに正しくレプリケートされません。


アニメーションの読み込みと再生

-- LocalScript in StarterCharacterScripts
local character = script.Parent
local animator = character:WaitForChild("Humanoid"):WaitForChild("Animator")

local animation = Instance.new("Animation")
animation.AnimationId = "rbxassetid://1234567890"

local track = animator:LoadAnimation(animation)

track:Play()                      -- default fade-in (0.1s), weight 1, speed 1
track:Play(0.1, 1, 0.5)          -- fadeTime, weight, speed

track:AdjustSpeed(1.5)           -- change speed while playing
track:AdjustWeight(0.5, 0.2)     -- weight 0.5, fade over 0.2s

track:Stop()                      -- default fade-out (0.1s)
track:Stop(0.5)                   -- fade out over 0.5s

AnimationTrack のイベント

-- Fires after fade-out completes
track.Stopped:Connect(function()
    print("Animation finished")
end)

-- Use :Once for one-shot cleanup
track.Stopped:Once(function()
    cleanup()
end)

-- Fires when a named keyframe marker is reached
-- Marker names are set in the Roblox Animation Editor
track:GetMarkerReachedSignal("FootStep"):Connect(function(paramString)
    playFootstepSound()
end)

ループ再生とワンショット

プロパティループワンショット
track.Loopedtruefalse
設定場所Animation Editor(ループトグル)Animation Editor
実行時の上書きtrack.Looped = falsetrack.Looped = true
自動停止いいえ — track:Stop() を呼び出す必要がありますはい — 1 サイクル後に停止します
-- Force a looped animation to play once
track.Looped = false
track:Play()
track.Stopped:Once(function() print("Done") end)

アニメーションの優先度とブレンド

優先度は、競合するジョイントでどのトラックが優先されるかを制御します。優先度が高いほど低いものを上書きします。

Idle < Movement < Action < Action2 < Action3 < Action4 < Core
idleTrack.Priority   = Enum.AnimationPriority.Idle
runTrack.Priority    = Enum.AnimationPriority.Movement
attackTrack.Priority = Enum.AnimationPriority.Action

idleTrack:Play()
runTrack:Play()     -- overrides idle on shared joints
attackTrack:Play()  -- blends on top for joints it owns

2 つのトラックが同じ優先度を共有している場合、ウェイトが影響力を調整します:

trackA:Play(0, 0.6)  -- weight 0.6
trackB:Play(0, 0.4)  -- weight 0.4 — blended on shared joints

Humanoid と AnimationController

Humanoid(キャラクターおよびヒューマノイド NPC)
local animator = character:FindFirstChildOfClass("Humanoid"):FindFirstChildOfClass("Animator")
local track = animator:LoadAnimation(animation)
track:Play()
AnimationController(プロップ、乗り物、クリーチャー)
local controller = model:FindFirstChildOfClass("AnimationController")
local animator = controller:FindFirstChildOfClass("Animator")
if not animator then
    animator = Instance.new("Animator")
    animator.Parent = controller
end
local track = animator:LoadAnimation(animation)
track:Play()

デフォルトのキャラクターアニメーションの置き換え

キャラクター内の Animate LocalScript がアニメーション参照を保持しています。CharacterAdded でその AnimationId の値を変更してください。

-- LocalScript in StarterCharacterScripts
local animate = script.Parent:WaitForChild("Animate")

local function replaceAnim(slotName, newId)
    local slot = animate:FindFirstChild(slotName)
    if slot then
        local animObj = slot:FindFirstChildOfClass("Animation")
        if animObj then animObj.AnimationId = newId end
    end
end

replaceAnim("idle",  "rbxassetid://111111111")
replaceAnim("run",   "rbxassetid://222222222")
replaceAnim("jump",  "rbxassetid://333333333")
replaceAnim("fall",  "rbxassetid://444444444")
replaceAnim("climb", "rbxassetid://555555555")

使用可能なスロット: idle、walk、run、jump、fall、climb、swim、swimidle、toolnone、toolslash、toollunge。


再生中のすべてのアニメーションを停止する

local function stopAll(animator, fadeTime)
    for _, track in animator:GetPlayingAnimationTracks() do
        track:Stop(fadeTime or 0.1)
    end
end

再生のクイックリファレンス

track:Play(fadeTime, weight, speed)
-- fadeTime  default 0.1   — blend-in seconds
-- weight    default 1.0   — joint influence (0–1)
-- speed     default 1.0   — playback rate

track.TimePosition   -- current position in seconds (read/write)
track.Length         -- total duration in seconds
track.IsPlaying      -- bool
track.Looped         -- bool (override allowed at runtime)
track.Priority       -- Enum.AnimationPriority
track.WeightCurrent  -- actual blended weight right now
track.WeightTarget   -- target weight after fade

上半身のみのアニメーション

優先度ブレンドは、アニメーションが影響を与える すべてのジョイント に作用します。脚が run/idle でアニメーションしている間に腕だけで手を振るアニメーションを再生するには、アニメーション自体が上半身のボーンだけをキーするように作成されている必要があります(Animation Editor で下半身のジョイントはキーを付けないままにします)。ジョイントをマスクする実行時 API は存在しません — 解決策はスクリプトではなく、アニメーションアセットにあります。


よくある間違い

間違い修正方法
キャラクターのアニメーションを Script で再生しているStarterCharacterScripts 内の LocalScript を使用してください
LoadAnimation を Humanoid で呼び出している(非推奨)代わりに Animator で呼び出してください
2 つのアニメーションが同じジョイントで競合している異なる Priority 値を割り当ててください
Stopped が即座に発火するアニメーションの長さがゼロ、または Looped の設定が間違っています
GetMarkerReachedSignal がまったく発火しないマーカー名のスペルミス、またはマーカー追加後にアニメーションを再アップロードしていません
NPC のアニメーションが他のクライアントに表示されないLocalScript ではなく Script(サーバー)から再生してください
AnimationController のトラックが再生されないAnimationController 内に Animator の子がありません

コメント