【发布时间】:2021-03-25 01:25:10
【问题描述】:
有人可以帮助我演示如何让 NPC 通过路径移动,就像在 tds 游戏中一样?这个我试过了
local function move()
-- source is an array with all the positions it has to go to
for i=1,#source,1 do
-- This is in case the MoveTo takes more than 8 seconds
local itreached = false
while itreached == false do
npc.Humanoid:MoveTo(source[i].Position)
wait()
npc.Humanoid.MoveToFinished:Connect(function()
itreached = true
end)
end
end
end
它的工作范围很广,当我接近 npc 时,它会以某种方式下降和滞后,否则如果我只是在没有播放器的情况下运行它,它就可以正常工作。是否有其他技术,例如 lerp 或 tween?我尝试使用 lerp,但我无法移动整个模型。
【问题讨论】:
-
如果您使用寻路,移动到是要走的路。我建议您阅读 Roblox 在开发中心中关于寻路的教程。