Animator

显示已弃用

*此内容使用人工智能(Beta)翻译,可能包含错误。若要查看英文页面,请点按 此处

负责播放和复制 Animations 的主要类别。所有播放的复制 AnimationTracks 都通过 Animator 实例进行处理。

还请参阅动画编辑器使用动画来学习如何创建和添加预制或自定义动画到您的游戏。

概要

属性

方法

属性

EvaluationThrottled

只读
未复制
不可浏览
写入并联

PreferLodEnabled

读取并联

RootMotion

只读
未复制
不可浏览
写入并联

RootMotionWeight

只读
未复制
不可浏览
写入并联

方法

ApplyJointVelocities

()

参数

motors: Variant
默认值:""

返回

()

GetPlayingAnimationTracks


返回

LoadAnimation

参数

animation: Animation
默认值:""

返回

RegisterEvaluationParallelCallback

()

参数

callback: function
默认值:""

返回

()

StepAnimations

()
插件安全性

参数

deltaTime: number
默认值:""

返回

()

代码示例

在工作室预览动画

local RunService = game:GetService("RunService")
local function studioPreviewAnimation(model, animation)
-- 找到动画控制器和动画师
local animationController = model:FindFirstChildOfClass("Humanoid")
or model:FindFirstChildOfClass("AnimationController")
local animator = animationController and animationController:FindFirstChildOfClass("Animator")
if not animationController or not animator then
return
end
-- 加载动画以创建动画跟踪
local track = animationController:LoadAnimation(animation)
track:Play()
-- 预览动画
local startTime = tick()
while (tick() - startTime) < track.Length do
local step = RunService.Heartbeat:wait()
animator:StepAnimations(step)
end
-- 停止动画
track:Stop(0)
animator:StepAnimations(0)
-- 重置关节
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"
studioPreviewAnimation(character, animation)

活动

AnimationPlayed

参数

animationTrack: AnimationTrack