Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Collision Filtering does not want to work?

Asked by 2 years ago

I wanted to learn about this service so I followed the developer hub and came up with the code that I here. The only problem is that is doesn't want to work at all. I have no idea what goes wrong because I get no errors. Help is very appreciated.????

local PhysicsService = game:GetService("PhysicsService")

-- Define parts
local part = game.Workspace.Part
local notCollide = game.Workspace.NotCollide
local collide = game.Workspace.Collide

-- Create group names
local obstacles = "Obstacles"
local greenObjects = "GreenObjects"
local partGroup = "Part"

-- Create the collision groups
PhysicsService:CreateCollisionGroup(obstacles)
PhysicsService:CreateCollisionGroup(greenObjects)
PhysicsService:CreateCollisionGroup(partGroup)

-- Add the object to the groups
PhysicsService:SetPartCollisionGroup(notCollide, obstacles)
PhysicsService:SetPartCollisionGroup(collide, greenObjects)

PhysicsService:CollisionGroupSetCollidable(obstacles, partGroup, false) -- Sets the collision of the part and the obstacle
--to be false
PhysicsService:CollisionGroupSetCollidable(greenObjects, partGroup, true) -- Sets the collision of the part and the obstacle
--to be true

1 answer

Log in to vote
0
Answered by 2 years ago

Figured it out. I forgot to set a group to my part that I need to actually not collide with the other part. Where I set the objects to their collision group, all I needed was this:

PhysicsService:SetPartCollisionGroup(notCollide, obstacles)
PhysicsService:SetPartCollisionGroup(collide, greenObjects)
PhysicsService:SetPartCollisionGroup(part, partGroup)
Ad

Answer this question