New Part Collision Property: CanQuery - Now Available!

This feature is now enabled everywhere as of 1/5/2022

A third collision option is now added to compliment CanCollide and CanTouch, called CanQuery.

CanQuery

This property lets you determine if the part will be hit by spatial queries, such as raycasts or bound overlap checks. A part that has CanQuery set to False will always be ignored by spatial queries, even if the part is whitelisted.

CanQuery can only be set if the part also has CanCollide turned off. It will be hidden in the Properties window unless you disable CanCollide. If you otherwise set it to be false while CanCollide is still true, it has no effect (the part will still be hit by spatial queries).

Let’s recap:

CanCollide - determines if the Part will be hit by other parts as physical collisions.

CanTouch - determines if the Part will trigger touch events touch events on itself and other parts.

CanQuery - determines if the Part will be hit by spatial query methods (raycast, overlap, region3).

This means, you can disable all three and the Part will be excluded from all collision computations. As you can expect, this can provide a significant performance benefit. Like I mentioned with the release of CanTouch, you may see some improvements now, with better ones coming down the road.

CanQuery Beta

Edit: the property is out of beta and is now live for everyone as of Jan 5th!

This is being released as a beta feature so we can test out a few things and address known issues:

  1. You may have realized that excluding a part from raycasts will lead to the part being unselectable by the Studio dragger tools. You’re right, this is a known issue. The dragger tools will be updated to override the property in Studio during the beta so you can still select things.

    We realize that the ability to disable selection on parts can be helpful. Over time, the dragger’s behavior will be extended to allow this. Tell us your thoughts on this!

  2. We decided to reorganize the Part property ordering in order to put all the Collision properties in one category. Feel free to leave feedback on this as well.

  3. Make sure there are no unforeseen issues, of course!

344 Likes

This topic was automatically opened after 15 minutes.

Will the HumanoidRootPart automatically have CanQuery set to false?

38 Likes

So besides improving spatial queries, is there any significant performance boost to setting CanQuery to false, like the slight boost from CanCollide and CanTouch both being set to false?

11 Likes

Wait, there’s a performance boost from setting CanTouch to false?!

12 Likes

A very slight boost, and only if CanCollide and CanTouch are both set to false.

EDIT: source, courtesy of @PersonifiedPizza

9 Likes

Correct me if I’m wrong but doesn’t BasePart.Locked property exist for this purpose? I’m not sure why CanQuery should behave the same way in studio in full release when another property exist for that very specific reason.

Edit: My question is answered here:

13 Likes

My guess is its a slight performance boost like CanCollide and CanTouch both being set to false

but all of them together results in a significant boost for said part

7 Likes

Isn’t this what BasePart.Locked does?

I’m so thankful this is happening! I had to make functions that would filter out unsolid parts (which isn’t too complicated, but still needs the extra code), but now I can just turn off a property and have a simple raycast! Thanks!

7 Likes

Ah right, the answer’s in the OP lol. I guess we’re to take it as they all need to be set to off to see a minor performance boost, so it’s probably worth going through all of the nonessential parts in a game and doing so in the future.

3 Likes

This is one pretty useful feature for optimizing background elements you want to be completely be ignored.
I love how Roblox has lately worked more on updates like raycast and other optimizations, they are so much needed, they make the engine so much faster on older devices or devices with limited power.

16 Likes

Locked does something slightly different: Clicking on something that’s locked will specifically act as though you clicked on nothing. Clicking on something that’s CanQuery = false will currently act as though you clicked on whatever lies beyond it.

20 Likes

This is something especially needed for plugins. Being able to disable selection for specific parts (while having the dragger raycast pass through) is a feature I’ve been waiting for.

I got excited about this beta, but since preventing selection is unintentional behaviour, I’m a little disappointed now.

5 Likes

In Part.Locked the raycast still hits the part, but it is just not selected. With the CanQuery the raycast itself will ignore the part, that means you will be able to select a part behind a part, you are not able to do that with Part.Locked.

4 Likes

So will this allow a part with Query set to false to not be clicked by the draggers in studio? I always would try to set transparent parts (such as ones just to block players from wandering where they shouldnt) as locked only to be blocked when trying to click parts through them. It was very annoying, so I stopped using lock, as it really served no purpose for me.

6 Likes

Wondering if this somehow has something to do with the Pathfinding Service in the future. A nice addition to have though.

5 Likes

holy crap this is SO HELPFUL thank you so much Roblox, now i can finally ignore the HumanoidRootPart within raycasts for melees

6 Likes

FYI, you could always ignore or whitelist specific BaseParts in the Workspace. Just input a RaycastParams parameter to your Workspace:Raycast call:

local Workspace = game:GetService("Workspace")

local humanoidRootPart = ...

local raycastParams = RaycastParams.new()
raycastParams.FilterType = Enum.RaycastFilterType.Blacklist
raycastParams.FilterDescendantsInstances = { humanoidRootPart }

local origin = Vector3.new()
local direction = Vector3.new(0, 1, 0)

Workspace:Raycast(origin, direction, raycastParams)
10 Likes

Locked does not let you select parts behind the Locked part.

4 Likes

Will this work with Workspace:FindPartOnRay or is it just Workspace:Raycast?

4 Likes