Roblox Studio 动画无法播放

问题描述 投票:0回答:1

所以,我想做一个简单的任务,即当你在游戏中生成时在玩家上播放动画。 我很困惑为什么它没有播放,因为我直接从 Roblox 文档中撕下了脚本(除了我添加了自己的动画)。

local Players = game:GetService("Players")

local player = Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()

-- Ensure that the character's humanoid contains an "Animator" object
local humanoid = character:WaitForChild("Humanoid")
local animator = humanoid:WaitForChild("Animator")

-- Create a new "Animation" instance and assign an animation asset ID
local myAnimation = Instance.new("Animation")
myAnimation.AnimationId = "rbxassetid://88287635939752"

-- Load the animation onto the animator
local myAnimationTrack = animator:LoadAnimation(myAnimation)

-- Play the animation track
myAnimationTrack:Play()

这是 StartPlayerScripts 中的本地脚本

我测试了动画本身,它在具有人形机器人的假人上运行得非常好。 我已经打印了所有变量的类和名称,它们都返回了它们应该返回的内容。 问题可能出在哪里?

animation roblox luau
1个回答
0
投票

动画似乎无法播放的原因有多种:

  1. 确保您的角色与动画位于同一装备中。 R6 动画不适用于 R15,反之亦然。
  2. 在脚本顶部添加
    task.wait(5)
    并再次进行游戏测试。如果您有一个简短的动画,则该动画可能是在游戏测试启动时播放的。
  3. 确保动画由游戏创建者上传/上传至同一组。您可能需要检查输出是否有任何加载错误。
© www.soinside.com 2019 - 2024. All rights reserved.