Apprendre
Classe de moteur
Animator

*Ce contenu est traduit en utilisant l'IA (Beta) et peut contenir des erreurs. Pour consulter cette page en anglais, clique ici.



Référence API
Propriétés
EvaluationThrottled
Lecture uniquement
Non répliqué
Écrire en parallèle
Capacités : Animation
Animator.EvaluationThrottled:boolean

PreferLodEnabled
Lecture parallèle
Capacités : Animation
Animator.PreferLodEnabled:boolean

RootMotion
Lecture uniquement
Non répliqué
Non navigable
Écrire en parallèle
Capacités : Animation
Animator.RootMotion:CFrame

RootMotionWeight
Lecture uniquement
Non répliqué
Non navigable
Écrire en parallèle
Capacités : Animation
Animator.RootMotionWeight:number

Méthodes
ApplyJointVelocities
Capacités : Animation
Animator:ApplyJointVelocities(motors:Variant):()
Paramètres
motors:Variant
Retours
()

GetPlayingAnimationTracks
Capacités : Animation
Accès à la simulation
Animator:GetPlayingAnimationTracks():{any}
Retours

GetTrackByAnimationId
Capacités : Animation
Accès à la simulation
Animator:GetTrackByAnimationId(animationId:ContentId):AnimationTrack?
Paramètres
animationId:ContentId
Échantillons de code
Obtenir la piste d'animation par 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()
-- Assurez-vous que le humanoïde du personnage contient un objet Animator
local humanoid = character:WaitForChild("Humanoid")
local animator = humanoid:WaitForChild("Animator")
-- Créez une nouvelle instance d'Animation et assignez un ID d'actif d'animation
local kickAnimation = Instance.new("Animation")
kickAnimation.AnimationId = ANIM_ID
-- Chargez l'animation sur l'animateur
local kickAnimationTrack = animator:LoadAnimation(kickAnimation)
-- Jouez la piste d'animation après un court délai
task.wait(3)
kickAnimationTrack:Play()
local startTime = tick()
RunService:BindToSimulation(function(deltaTime: number)
if tick() - startTime > 1 then
-- Obtenez la piste par ID et arrêtez sa lecture
local kickTrack = animator:GetTrackByAnimationId(ANIM_ID)
if kickTrack and kickTrack.IsPlaying then
kickTrack:Stop()
end
end
end)

LoadAnimation
Capacités : Animation
Accès à la simulation
Animator:LoadAnimation(animation:Animation):AnimationTrack
Paramètres
animation:Animation

RegisterEvaluationParallelCallback
Capacités : Animation
Animator:RegisterEvaluationParallelCallback(callback:function):()
Paramètres
callback:function
Retours
()

StepAnimations
Sécurité des plugins
Capacités : Animation
Animator:StepAnimations(deltaTime:number):()
Paramètres
deltaTime:number
Retours
()
Échantillons de code
Aperçu de l'animation dans Studio
local RunService = game:GetService("RunService")
local function previewAnimation(model, animation)
-- Trouver l'AnimationController et l'Animator
local animationController = model:FindFirstChildOfClass("AnimationController")
local animator = animationController and animationController:FindFirstChildOfClass("Animator")
if not animator then return end
-- Charger l'Animation pour créer un AnimationTrack
local track = animationController:LoadAnimation(animation)
track:Play()
-- Prévisualiser l'animation
local startTime = tick()
while (tick() - startTime) < track.Length do
local step = RunService.Heartbeat:wait()
animator:StepAnimations(step)
end
-- Arrêter l'animation
track:Stop(0)
animator:StepAnimations(0)
-- Réinitialiser les articulations
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)

Événements
AnimationPlayed
Capacités : Animation
Animator.AnimationPlayed(animationTrack:AnimationTrack):RBXScriptSignal
Paramètres
animationTrack:AnimationTrack

©2026 Société Roblox. Roblox, le logo Roblox et Powering Imagination font partie de nos marques déposées aux États-Unis et dans d'autres pays.