RaycastParams.RespectCanCollide doesn't work

Description
Property of RaycastParams.new() called “RespectCanCollide” doesn’t respect CanQuery over CanCollide property of a part, when calling a WorldRoot:Raycast() method with RaycastParams being a parameter.

Visual aid:


This code creates a Raycast based on your mouse position and then prints the RaycastResult. It also demonstrates how RespectCanCollide is set to false.


This video shows how TestPart still gets detected, even though CanQuery is off and RespectCanCollide is set to false. CanCollide is still on.

Reproduction File
RespectCanCollide.rbxl (52.8 KB)

Expected behavior
I expect for TestPart not to be detected whenever I hover it when it has CanQuery off, and Raycast paramater “RespectCanCollide” set to false.

2 Likes

Um pretty sure respectcancollide’s default value is false. So I don’t think you’re changing anything. False will mean that it will only whitelist parts that have canquery off. SO in theory it shouldn’t be detected so I’m not sure why it is, try setting it to true. Even though in theory it will take the cancollide value instead of canquery. Try it anyways, if that doesn’t work try messing around with cancollide. I’m not sure if you can turn canquery off without turning cancollide off too though. So maybe that might be a problem.

Edit: Yes, you cant turn canquery off without turning cancollide off. So that may also be the reason why it isn’t working.

Edit2: “So I don’t think you’re changing anything. False will mean that it will only whitelist parts that have canquery off.” I wrote that wrong, meant to say that parts will be ignored if canquery is off. The parts which have canquery off of course.

I believe CanCollide having any effect on Raycast detection while RespectCanCollide is set to false is not expected behavior. That’s why I posted this bug report.

I thought it was scripting support my bad. But maybe give the things I said a test anyway so that if they do work/not work in intended/unintended ways you can add that to the report?

1 Like

Np. Already done, however I was never able to achieve the desired effect.

Well yeah then definitely a bug, wonder why mods haven’t come though.

Sorry for the confusion. Below is the doc for RespectCanCollide

This property, if true, makes the raycast operation use an intersected part’s CanCollide value in favor of its CanQuery value when determining whether that part is included in the RaycastResult.

By default, it’s false, When it false, the override is disabled.

CanQuery determines whether the part is considered during spatial query operations, such as GetPartBoundsInBox or Raycast. CanCollide must also be disabled when disabling CanQuery. These functions will never include parts whose CanQuery and CanCollide is false.

1 Like

Ah, thanks for letting me know. Would be great to see this work one day though.

Not sure if you’re aware, but that’s the kind of thing you can achieve with collision groups instead. Much better suited for it too.

3 Likes

Yes, I would use collision group for much better organization of the code.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.