How would i make a npc not collide with anything?

I understand there is collision groups, However i do not understand it what so ever.

1 Like

What do you mean by “not collide with anything”? You could make a collision group that doesn’t collide with the default collision group but that means it’ll fall through the baseplate.

Yes by collide with anything i mean collide with absolutely nothing, I am using raycasting to keep it above.


this is a example of the problem. But to make it easier id rather it collide with nothing.

I see, you can make a collision group and add it to the group like so:

local physicsService = game:GetService('PhysicsService')

physicsService:CreateCollisionGroup('NPCs') -- the NPC collision group
-- we don't have to define a collision group for the workspace since the default one already exists, it's called "Default"

physicsService:CollisionGroupSetCollidable('NPCs', 'Default', false) -- set the NPCs collision group to not collide with the default collision group
physicsService:CollisionGroupSetCollidable('NPCs', 'NPCs', false) -- set the NPCs collision group to not collide with other NPCs

local function setNPCCollisionGroup(npc: Model) -- this function will take an NPC and add all of its BasePart descendants to the NPCs collision group
    for i,v in ipairs(npc:GetDescendants()) do
        if not v:IsA('BasePart') then
            continue
        end
        physicsService:SetPartCollisionGroup(v, 'NPCs')
    end
end

local newNPC = serverStorage:FindFirstChild('NPC'):Clone()
setNPCCollisionGroup(newNPC) -- now with our new NPC, call the function to set all of its descendants to the NPCs collision group

Think of collision groups’ “collidability” in a grid pattern, each collision group either can or cannot collide with another collision group.

-
Default NPCs
Default
âś“
X
NPCs
X
X

“Default” can collide with “Default”
“Default” cannot collide with “NPCs”
“NPCs” cannot collide with “NPCs”

5 Likes

I appreciate your time for helping me, I have fixed the issue, Thanks!

1 Like