Ghi chú phát hành
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

PreferLodEnabled
Đọc Song Song
Các khả năng: Animation
Animator.PreferLodEnabled:boolean

RootMotion
Chỉ Đọc
Không Sao Chép
Không Thể Duyệt
Ghi Song Song
Các khả năng: Animation
Animator.RootMotion:CFrame

RootMotionWeight
Chỉ Đọc
Không Sao Chép
Không Thể Duyệt
Ghi Song Song
Các khả năng: Animation
Animator.RootMotionWeight:number

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 Animation Track 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 humanoid của nhân vật chứa một đối tượng Animator
local humanoid = character:WaitForChild("Humanoid")
local animator = humanoid:WaitForChild("Animator")
-- Tạo một instance Animation mới và gán một ID tài sản hoạt ảnh
local kickAnimation = Instance.new("Animation")
kickAnimation.AnimationId = ANIM_ID
-- Tải hoạt ảnh lên animator
local kickAnimationTrack = animator:LoadAnimation(kickAnimation)
-- Phát animation track 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 track 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

RegisterEvaluationParallelCallback
Các khả năng: Animation
Animator:RegisterEvaluationParallelCallback(callback:function):()
Tham Số
callback:function
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 hì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 ra 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.