As a developer, it is painful to use rays (or related features such as ClickDetectors) because of noise from irrelevant parts. Here are a few examples of blockers:
An invisible collider that determines when a door will open on Touched
An invisible wall that prevent walking into certain areas
A visible hologram MeshPart
These blockers prevent:
Clicking a ClickDetector behind the part
Shooting a bullet behind the part (ray will hit the part)
Targeting something behind the part (mouse.Hit will be on the part instead of on the target)
If ROBLOX is able to address this issue, it would improve my game development experience by not having to write custom ClickDetectors or implement a global whitelist that every raycast in the place uses.
A Solution:
Something akin to Unity’s Layer System. This would allow us not only to globally ignore parts from raycasts, but to group parts so they can be selectively applied to raycats without having to add/subtract from ignore tables in Lua.
When I cast a ray with no ignore list I expect it to return whatever part is in its way. I don’t want weird bugs or exploits appearing because of some interaction with a second ignore list. 1 is plenty imo.
Multiple ignore lists for individual rays and a global ignore list are different. Global ignore lists have a clear benefit over current solutions as described in the OP. Regarding exploits: “never trust the client”. They can say they hit something they didn’t or say they missed something they didn’t regardless.
This global ignore list doesn’t even solve any problems really. You’re telling me that every ray in your game serves the same purpose (e.g. a bullet) so you want to fire-and-forget an ignore list and have roblox just insert those objects into every ray’s ignore list forever?
This behavior is bad. First of all it’s not even a proper solution because bullet rays aren’t the only thing in your game. The camera fires rays too, so the moment you want bullets to ignore something but the camera to collide with it you’re back to using a proper ignore list management system which makes the whole feature moot.
The use case for this is very fragile, and you want to uproot every game’s expectations of how raycasts behave in order to implement it.
Developers can implement this in their own games better than roblox ever could. You should just manage your ignore lists properly and you’ll be able to do this and more on your own.
No, every ray does not serve the same purpose. There are parts that should never be interacting with any ray unless explicitly specified. An invisible floating part holding a PointLight with no collisions should not interfere with:
A bullet
ClickDetectors
The camera
A scanner that scans whatever the mouse is over
Detecting which NPC the mouse is over for dialogue
etc
There are legitimately parts that should not interfere with rays ever. Yes I want ROBLOX to ignore these objects for raycasting forever, and yes that is appropriate behavior. This sounds like you not understanding use case rather than any criticism of the feature. If you’re able to, please provide an explanation to why an invisible, floating part without collisions for lights should be detected by raycasts.
Sounds like the problem is the way developers have to implement light sources, then. IIRC there is some coming soon feature that lets you put lights inside of attachments. @Davidii was working on this I believe.
Lights are already able to be placed in attachments. I am not using attachments because then it becomes impossible to hunt down which part a light is attached to. The solution for this is a plugin which adds 3D buttons for lights/sounds/etc, but this is not the point of the feature request. There exist objects that should never be picked up by rays. Further examples were provided in the OP. An invisible, CanCollide=false collision detector for a door should not interfere with:
A bullet
ClickDetectors
The camera
A scanner that scans whatever the mouse is over
Detecting which NPC the mouse is over for dialogue
etc
You’re wrong that no objects should be globally ignored by rays. Looking at the Unity API, they too have this functionality in the form of a built-in “Ignore Raycast” layer. Unity’s implementation is more useful actually, so I’ve updated the OP to suggest that.
Perhaps we can simplify this by allowing us to whitelist/blacklist certain CollectionService tags nicely.
That’d be useful. Though this is do-able in lua it’s rather tedious to modify tables to insert or remove certain objects, especially as the tags grow.
Might be worth bringing up weapons which ignore hats.
It’s a bit annoying to try and juggle all hats in a list clientside. You have to add them as they are created and remove them as characters die, leave the game, etc.
Then, that list has to be available in every script you use raycasting in.
And finally, it’s not fun to have to merge a copy of the hat list with whatever else you wanted to ignore for that ray.
I think the global ignore list is a great idea and I think it would be amazing if there was a boolean property, called something like “Ignore,” added to parts and other physical objects, including models, in order to easily edit what you wanted to be ignored.
We’re considering the possibilities of making raycasts work with CollectionService and CollisionGroups, or supply filters for common use cases (like return only body parts of characters) as well as a GetNPartsOnRay that returns an ordered list of up to N hit things that you can loop over yourself, as part of future improvements as time allows and features warrant.