Học
Lớp công cụ
Animator

*Nội dung này được dịch bằng AI (Beta) và có thể có lỗi. Để xem trang này bằng tiếng Anh, hãy nhấp vào đây.


Tóm Tắt
Sự Kiện
Thành viên kế thừa

Tài Liệu Tham Khảo API
Thuộc Tính
EvaluationThrottled
Chỉ Đọc
Không Sao Chép
Ghi Song Song
Các khả năng: Animation
Animator.EvaluationThrottled:boolean
Mẫu mã
Đánh giá bị giới hạn
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
Đọc Song Song
Các khả năng: Animation
Animator.PreferLodEnabled:boolean

Phương Pháp
ApplyJointVelocities
Các khả năng: Animation
Animator:ApplyJointVelocities(motors:Variant):()
Tham Số
motors:Variant
Lợi Nhuận
()

GetPlayingAnimationTracks
Các khả năng: Animation
Quyền sử dụng chế độ mô phỏng
Animator:GetPlayingAnimationTracks():{any}
Lợi Nhuận

GetTrackByAnimationId
Các khả năng: Animation
Quyền sử dụng chế độ mô phỏng
Animator:GetTrackByAnimationId(animationId:ContentId):AnimationTrack?
Tham Số
animationId:ContentId
Lợi Nhuận
Mẫu mã
Lấy Đường Dẫn Hoạt Hình theo 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()
-- Đảm bảo rằng nhân vật có một đối tượng Animator trong humanoid
local humanoid = character:WaitForChild("Humanoid")
local animator = humanoid:WaitForChild("Animator")
-- Tạo một thể hiện Animation mới và gán một ID tài sản hoạt hình
local kickAnimation = Instance.new("Animation")
kickAnimation.AnimationId = ANIM_ID
-- Tải hoạt hình lên animator
local kickAnimationTrack = animator:LoadAnimation(kickAnimation)
-- Phát đường dẫn hoạt hình sau một khoảng thời gian ngắn
task.wait(3)
kickAnimationTrack:Play()
local startTime = tick()
RunService:BindToSimulation(function(deltaTime: number)
if tick() - startTime > 1 then
-- Lấy đường dẫn theo ID và dừng phát nó
local kickTrack = animator:GetTrackByAnimationId(ANIM_ID)
if kickTrack and kickTrack.IsPlaying then
kickTrack:Stop()
end
end
end)

LoadAnimation
Các khả năng: Animation
Quyền sử dụng chế độ mô phỏng
Animator:LoadAnimation(animation:Animation):AnimationTrack
Tham Số
animation:Animation
Lợi Nhuận

StepAnimations
Bảo Mật Plugin
Các khả năng: Animation
Animator:StepAnimations(deltaTime:number):()
Tham Số
deltaTime:number
Lợi Nhuận
()
Mẫu mã
Xem trước hoạt ảnh trong Studio
local RunService = game:GetService("RunService")
local function previewAnimation(model, animation)
-- Tìm AnimationController và Animator
local animationController = model:FindFirstChildOfClass("AnimationController")
local animator = animationController and animationController:FindFirstChildOfClass("Animator")
if not animator then return end
-- Tải hoạt ảnh để tạo một AnimationTrack
local track = animationController:LoadAnimation(animation)
track:Play()
-- Xem trước hoạt ảnh
local startTime = tick()
while (tick() - startTime) < track.Length do
local step = RunService.Heartbeat:wait()
animator:StepAnimations(step)
end
-- Dừng hoạt ảnh
track:Stop(0)
animator:StepAnimations(0)
-- Đặt lại các khớp
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)

Sự Kiện
AnimationPlayed
Các khả năng: Animation
Animator.AnimationPlayed(animationTrack:AnimationTrack):RBXScriptSignal
Tham Số
animationTrack:AnimationTrack

©2026 Roblox Corporation. Roblox, logo Roblox và Powering Imagination là các nhãn hiệu đã đăng ký và chưa đăng ký của chúng tôi tại Hoa Kỳ và các quốc gia khác.