首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >罗伯克斯:让鼻咽癌变得不可移动?

罗伯克斯:让鼻咽癌变得不可移动?
EN

Stack Overflow用户
提问于 2018-09-13 10:22:42
回答 3查看 576关注 0票数 2

我目前正在开发一款包含大量NPC的游戏,我需要一种方法来让玩家不能以任何方式移动它们。我试过锚定HumanoidRootPart,它起作用了,但它使NPC无法移动。

有人能帮上忙吗?

EN

回答 3

Stack Overflow用户

发布于 2020-12-04 08:19:01

如果可能的话,你可以把NPC焊接到地面上。

这可能是可行的:

代码语言:javascript
复制
local weld = Instance.new("WeldConstraint")
weld.Part0 = part
weld.Part1 = otherPart
weld.Parent = part

这里有更多关于焊接的信息here

如果你不需要玩家通过这些NPC,你可以“解开”NPC,允许玩家通过它但不能移动它。

代码语言:javascript
复制
local function setDescendantCollisionGroup(Descendant)
    if Descendant:IsA("BasePart") and Descendant.CanCollide then
        -- set collision group
    end
end

model.DescendantAdded:Connect(setDescendantCollisionGroup)
for _, descendant in pairs(model:GetDescendants()) do
    setDescendantCollisionGroup(descendant)
end
票数 1
EN

Stack Overflow用户

发布于 2018-09-14 03:43:45

这应该能够使用属性来完成。创建一个首发角色,让玩家佩戴这个角色,然后修改它的自定义物理属性“摩擦力”,“密度”到一个非常低的数字。

你也应该能够把这样的东西放在脚本中,比如当一个玩家加入时,带有类"Part“的孩子的密度和摩擦力都很低。

票数 0
EN

Stack Overflow用户

发布于 2021-08-11 09:38:27

尝试如下所示:

代码语言:javascript
复制
    local NPC = workspace.NPC --The NPC variable
    NPC.HumanoidRootPart.Mass = 69420

这应该会让全国人民代表大会变得更重!

当你想让它移动的时候:

代码语言:javascript
复制
    local NPC = workspace.NPC --The NPC variable
    NPC.HumanoidRootPart.Mass = 10

这将使全国人民代表大会更轻!

所以这是最终的脚本:

代码语言:javascript
复制
    local NPC = workspace.NPC --The NPC variable
    local humanoid = NPC:WaitForChild('Humanoid') --NPC's humanoid
    local hrp = NPC.HumanoidRootPart --NPC's HumanoidRootPart
    
    local mass1 = 69420
    local mass2 = 10
    
    humanoid.Running:Connect(function(speed)
        if speed > 0.001 then
            hrp.Mass = mass2
        else
            hrp.Mass = mass1
        end
    end)

确保在ServerScript中编写该代码!

如果需要,可以将脚本放入NPC中。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/52305790

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档