Meer informatie
Engine-klasse
Animator

*Deze inhoud is vertaald met behulp van AI (bèta) en kan fouten bevatten. Klik hier om deze pagina in het Engels te bekijken.


Samenvatting

Evenementen
Overgenomen leden

API-referentie
Eigenschappen
EvaluationThrottled
Alleen-lezen
Niet gerepliceerd
Parallel schrijven
Mogelijkheden: Animation
Animator.EvaluationThrottled:boolean
Codevoorbeelden
Evaluatie Beperkt
local RunService = game:GetService("RunService")
local Workspace = game:GetService("Workspace")
local animationController = Instance.new("AnimationController")
local animator = Instance.new("Animator")
animator.Parent = animationController
animationController.Parent = Workspace
local neck = Instance.new("Motor6D")
local function computeNeckRotation()
return CFrame.Angles(0, 0.01, 0)
end
RunService.PreSimulation:Connect(function()
if not animator.EvaluationThrottled then
neck.Transform = computeNeckRotation() * neck.Transform
end
end)

PreferLodEnabled
Parallel lezen
Mogelijkheden: Animation
Animator.PreferLodEnabled:boolean

Methoden
ApplyJointVelocities
Mogelijkheden: Animation
Animator:ApplyJointVelocities(motors:Variant):()
Parameters
motors:Variant
Teruggaves
()

GetPlayingAnimationTracks
Mogelijkheden: Animation
Toegang tot simulatie
Animator:GetPlayingAnimationTracks():{any}
Teruggaves

GetTrackByAnimationId
Mogelijkheden: Animation
Toegang tot simulatie
Animator:GetTrackByAnimationId(animationId:ContentId):AnimationTrack?
Parameters
animationId:ContentId
Teruggaves
Codevoorbeelden
Krijg Animatie Track op ID
local Players = game:GetService("Players")
local RunService = game:GetService("RunService")
local ANIM_ID = "rbxassetid://2515090838"
local player = Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
-- Zorg ervoor dat het humanoid van het personage een Animator object bevat
local humanoid = character:WaitForChild("Humanoid")
local animator = humanoid:WaitForChild("Animator")
-- Maak een nieuwe Animatie instantie en wijs een animatie asset ID toe
local kickAnimation = Instance.new("Animation")
kickAnimation.AnimationId = ANIM_ID
-- Laad de animatie op de animator
local kickAnimationTrack = animator:LoadAnimation(kickAnimation)
-- Speel de animatie track af na een korte vertraging
task.wait(3)
kickAnimationTrack:Play()
local startTime = tick()
RunService:BindToSimulation(function(deltaTime: number)
if tick() - startTime > 1 then
-- Krijg track op ID en stop de afspelen
local kickTrack = animator:GetTrackByAnimationId(ANIM_ID)
if kickTrack and kickTrack.IsPlaying then
kickTrack:Stop()
end
end
end)

LoadAnimation
Mogelijkheden: Animation
Toegang tot simulatie
Animator:LoadAnimation(animation:Animation):AnimationTrack
Parameters
animation:Animation
Teruggaves

StepAnimations
Mogelijkheden: Animation, PluginOrOpenCloud
Animator:StepAnimations(deltaTime:number):()
Parameters
deltaTime:number
Teruggaves
()
Codevoorbeelden
Voorbeeldanimatie in Studio
local RunService = game:GetService("RunService")
local function previewAnimation(model, animation)
-- Zoek de AnimationController en Animator
local animationController = model:FindFirstChildOfClass("AnimationController")
local animator = animationController and animationController:FindFirstChildOfClass("Animator")
if not animator then return end
-- Laad de animatie om een AnimationTrack te creëren
local track = animationController:LoadAnimation(animation)
track:Play()
-- Preview de animatie
local startTime = tick()
while (tick() - startTime) < track.Length do
local step = RunService.Heartbeat:wait()
animator:StepAnimations(step)
end
-- Stop de animatie
track:Stop(0)
animator:StepAnimations(0)
-- Reset de gewrichten
for _, descendant in pairs(model:GetDescendants()) do
if descendant:IsA("Motor6D") then
local joint = descendant
joint.CurrentAngle = 0
joint.Transform = CFrame.new()
end
end
end
local character = script.Parent
local animation = Instance.new("Animation")
animation.AnimationId = "rbxassetid://507765644"
previewAnimation(character, animation)

Evenementen
AnimationPlayed
Mogelijkheden: Animation
Animator.AnimationPlayed(animationTrack:AnimationTrack):RBXScriptSignal
Parameters
animationTrack:AnimationTrack

©2026 Roblox Corporation. Roblox, het Roblox-logo en Powering Imagination behoren tot onze geregistreerde en niet-geregistreerde handelsmerken in de VS en andere landen.