學習
引擎類別
AnimationController

*此內容是使用 AI(Beta 測試版)翻譯,可能含有錯誤。若要以英文檢視此頁面,請按一下這裡


概要
活動
繼承成員
範例程式碼
使用 AnimationController 動畫非玩家物件
local InsertService = game:GetService("InsertService")
-- 載入一個模型以進行演示
local npcModel = InsertService:LoadAsset(516159357):GetChildren()[1]
npcModel.Name = "NPC"
npcModel.PrimaryPart.Anchored = true
npcModel:SetPrimaryPartCFrame(CFrame.new(0, 5, 0))
npcModel.Parent = workspace
-- 用 animationcontroller 取代 humanoid
local humanoid = npcModel:FindFirstChildOfClass("Humanoid")
humanoid:Destroy()
local animationController = Instance.new("AnimationController")
animationController.Parent = npcModel
-- 創建並載入一個動畫
local animation = Instance.new("Animation")
animation.AnimationId = "http://www.roblox.com/asset/?id=507771019" -- Roblox 舞蹈表情
local animationTrack = animationController:LoadAnimation(animation)
-- 播放動畫
animationTrack:Play()

API 參考
方法
GetPlayingAnimationTracks
已棄用

LoadAnimation
已棄用

活動
AnimationPlayed
已棄用

©2026 Roblox Corporation、Roblox、Roblox 標誌及 Powering Imagination 是我們在美國及其他國家地區的部分註冊與未註冊商標。