为什么只从我的动画脚本中空闲播放

  • 本文关键字:脚本 播放 动画 lua roblox
  • 更新时间 :
  • 英文 :


所以我正在为Roblox上的自定义角色制作一个自定义动画脚本。人工智能运行良好,但它几乎总是只播放空闲的动画,即使是人形事件。

通常情况下,当怪物处于空闲状态时,应该播放空闲动画。行走时,应播放行走动画。当AI攻击时,应该播放攻击动画。

我已经把空闲的动画部分注释掉了,但之后根本没有动画播放。

这是代码:

local myHuman = script.Parent.Humanoid
local walkAnim = myHuman:LoadAnimation(script.Parent.Walk)
local idleAnim = myHuman:LoadAnimation(script.Parent.Idle)
local jumpAnim = myHuman:LoadAnimation(script.Parent.Jump)
myHuman.Running:Connect(function(speed)
if speed > 3 then
walkAnim:Play()
else
walkAnim:Stop()
idleAnim:Play()
end
end)
myHuman.Jumping:Connect(function()
jumpAnim:Play()
end)
myHuman.Died:Connect(function()
for i,v in pairs(myHuman:GetPlayingAnimationTracks()) do
v:Stop()
end
end)

试着添加一个打印而不是动画,看看会发生什么,并告诉我它是否打印了什么。

myHuman.Running:Connect(function(speed)
if speed > 3 then
print("walk")
else
print("start idle")
end
end)

编辑:https://devforum.roblox.com/t/getplayinganimationtracks-is-deprecated/1075650我相信你必须这样做myHuman.Animator:getPlayingAnimationTracks()

最新更新