I’ve been trying to get a raycast to ignore all parts it crosses except for those under the collision group “Hitboxes”.
But rather than acknowledging the collision group the raycast just functions as if it doesn’t exist, printing “nil” if you use Enum.RaycastFilterType.Include, and printing whichever part would usually hit first without parameters if you were to use Enum.RaycastFilterType.Exclude.
I’ve tried different combinations of checking and unchecking different groups in the collision groups menu but nothing changed.
However testing FilterDescendantsInstances I managed to get results so I believe this issue is specifically linked to CollisionGroups alone.
I have tried to find other ways to ignore certain groups of parts while raycasting, but all devfourm posts I could find reference back to using CollisionGroups, so I have no clue where to go from here.
Here’s my script just in case.
local a = workspace.sender
local b = workspace.target
local direction = b.Position - a.Position
local params = RaycastParams.new()
params.FilterType = Enum.RaycastFilterType.Include
params.CollisionGroup = "Hitboxes"
local raycastResult = workspace:Raycast(a.Position, direction, params)
print(raycastResult)
If you set filter type to Include and don’t set anything to the filter obviously it wont find anything since with a set collision group all it does is further expand the filtering, for example:
Collision Group A: Exclude Collision Group B but Include Itself
Collision Group B: Include Collision Group A and Include itself
Setting RaycastParams to use group A and setting filter type to Exclude will make it see only the coll group A, since that is what you set in coll group settings, but if you set it to use Include filter and put anything from coll group B it will still not return anything as A doesn’t collide with B, but if you set a part from group A to include in the raycast then it will only detect that part
Setting B as the coll group will act like the default raycast with no set collision group
“Hitboxes” collides with Default, so unless you put the wall into the ignore list then it will detect it
wait hol up it doesnt collide with it lemme rethink this
Make sure the raycast params are taking the correct Collision Group name (your code snippet shows that its correct but idk what else could be wrong cuz it works for me)
(extra stuff)
I was also having trouble with getting the part to collide with default collision afterwards, but I found you just need a separate collision group specifically for raycasting.