As a Roblox developer it is currently too hard to raycast (and blockcast, spherecast, etc…) while including / excluding specific instances, but not their descendants.
RaycastParams.FilterType
provides the option between an inclusion filter and a exclusion filter. However, both these filter types also include / exclude the descendants of any instances in the list. This becomes problematic when you want to do something like the following.
Run a raycast where you can hit ContainerPartA
and the Part
instances, but not ContainerPartB
.
For example, one way to do this currently would be to turn CanQuery
off for anything you want to ignore, but this also requires you to set CanCollide
to false as well. Since this is happening so quickly that likely won’t have any impact on the physics of your game. However, if you are watching property changed signals and don’t have defered signalling on then you may have some problems.
From a bigger picture you might say just don’t place BaseParts as children of other BaseParts, but I’ve found cases where that structure is super helpful when building games. I.e. weld all baseparts to their parent.
There are some solutions of other approaches I can think of, but every one I can think of has some kind of con to it or isn’t generalized enough. It would be nice to have a solution built into the API.
My proposed solution would be to add two new filter types:
Enum.RaycastFilterType.ExcludeWithoutDescendants
Enum.RaycastFilterType.IncludeWithoutDescendants
Thanks!