Camera:GetPartsObscuringTarget does not respect CanQuery property of partys

The following function does not respect the CanQuery property of parts

Repro file:
GetPartsObscuringTargetNonQuery.rbxl (53.0 KB)

Expected behavior

CanQuery false parts should not be queried, and therefore should not be returned in the list of baseparts that are obscuring the target.

I don’t believe this is a bug, this seems like expected behavior to me. Reading the documentation, the API only accepts two vector3s, and an array of parts to explicitly ignore. It doesn’t mention anything about cast parameters. Because this seems to be behaving how it should, you can get the behavior you want by looping through the parts this API returns & checking their cancollide property manually.

Having a newer modern API that accepted cast params would be nice though!

1 Like

Then the API should be updated to accept cast parameters

1 Like

Yep, that was covered in my reply :slight_smile:

1 Like

I believe this is a legacy method that was designed before the CanQuery property was added, and can’t be changed because the built-in camera scripts and some other legacy modules use it for camera occlusion. For certain modes, the camera module uses this to not render parts between the camera and the character. If the behavior of this method were to be changed to respect CanQuery, parts that have CanQuery disabled would block the view of the camera. (for example if you turned CanQuery off in the character model, it wouldn’t become invisible when you went into first person mode) I’m also pretty sure this doesn’t perform a query at all (at least not in the same way as raycast), since this is a camera method, and instead grabs object data directly from the rendering engine