负责播放和复制 Animations 的主要类别。所有播放的复制 AnimationTracks 都通过 Animator 实例进行处理。
概要
属性
方法
计算零件之间的相对速度,并将其应用到 Motor6D.Part1 。这些相对速度计算和分配发生在提供的顺序。
返回正在播放的列表 AnimationTracks .
将 Animation 加载到 Animator 上,返回一个 AnimationTrack 。
增加所有加载到 AnimationTrack.TimePosition 上的所有播放 AnimationTracks 的 Animator 值,将抵消应用到与 Animator 相关的模型。仅供命令栏或插件使用。
活动
当动画师开始播放动画时触发。
属性
方法
ApplyJointVelocities
()
参数
motors: Variant
默认值:""
返回
()
StepAnimations
()
参数
默认值:""
返回
()
代码示例
在工作室预览动画
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)