AnimationController
*Ta zawartość będzie dostępna wkrótce w wybranym przez ciebie języku.
An object which allows animations to be loaded and applied to a character or model in place of a Humanoid. Creates an Animator and loads animations to update Motor6Ds of said character to react in the way that is described within the animation asset referenced by an Animation object.
Note that the LoadAnimation() method of this class has been deprecated. Instead, you should call Animator:LoadAnimation() directly from an Animator which can be created manually in Studio and directly referenced in scripts. When the deprecated method is called from an AnimationController, the controller itself does nothing regarding the animation intended to be loaded, except to automatically generate an Animator, onto which the loading call and animation ID are transferred. In this way, the AnimationController can be thought of as nothing more than an empty shell for a child Animator object which handles any actual functionality regarding animations.
Przykłady kodu
local InsertService = game:GetService("InsertService")
-- Load a model for demonstration
local npcModel = InsertService:LoadAsset(516159357):GetChildren()[1]
npcModel.Name = "NPC"
npcModel.PrimaryPart.Anchored = true
npcModel:SetPrimaryPartCFrame(CFrame.new(0, 5, 0))
npcModel.Parent = workspace
-- Replace the humanoid with an animationcontroller
local humanoid = npcModel:FindFirstChildOfClass("Humanoid")
humanoid:Destroy()
local animationController = Instance.new("AnimationController")
animationController.Parent = npcModel
-- Create and load an animation
local animation = Instance.new("Animation")
animation.AnimationId = "http://www.roblox.com/asset/?id=507771019" -- Roblox dance emote
local animationTrack = animationController:LoadAnimation(animation)
-- Play the animation
animationTrack:Play()