【问题标题】:How to fix NPCs flinging off map/falling apart如何修复 NPC 脱离地图/分崩离析
【发布时间】:2020-12-27 00:45:04
【问题描述】:

我刚刚制作了一个脚本,使用下面的脚本将 NPC 克隆到随机位置,但是 NPC 不会出现在我在脚本中声明的任何生成位置,而只会出现在实际地图的中间。它们在克隆时也会分崩离析/从地图上飞出。我应该用一张桌子来解决这个问题吗?如何解决?

local module = {}

wavepause = game.ReplicatedStorage.Values.WavePauseLength.Value
trollanoid = game.ReplicatedStorage.Trollanoid
spawnpoints = workspace.Test1.Spawns:GetChildren()

function trollanoidsummon()
    local chosenspawn = spawnpoints[math.random(#spawnpoints)]
    local clone = trollanoid:Clone()
    clone.Parent = workspace.Zombies
    clone.UpperTorso.Position = chosenspawn.Position
end

module.Wave1 = function()
    wait(20)
    trollanoidsummon()
    wait(1)
    trollanoidsummon()
    wait(1)
    trollanoidsummon()
    wait(1)
    trollanoidsummon()
end

return module

【问题讨论】:

    标签: lua roblox


    【解决方案1】:

    尝试设置 HumanoidRootPart 的 CFrame

    function trollanoidsummon()
        local chosenspawn = spawnpoints[math.random(#spawnpoints)]
        local clone = trollanoid:Clone()
        clone.Parent = workspace.Zombies
        clone.HumanoidRootPart.CFrame= chosenspawn.CFrame
    end
    

    【讨论】:

    • 我试过了,现在他们只会毁了自己。脚本和人形机器人在模型中仍然完好无损。
    • CaptinLetus,模型也有函数 SetPrimaryPartCFrame()。你也可以打电话给clone:SetPrimaryPartCFrame(chosenSpawn.CFrame) 这样做
    猜你喜欢
    • 2012-05-01
    • 2022-06-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多