So I’ve ran into an issue while raycasting in Parallel. A little while ago Roblox made it so you couldn’t change the FilterDescendantsInstances property of RaycastParameters in parallel and to help developers continue to raycast in parallel they created AddToFilter.
This method works really well for Blacklists. Hit a part? Don’t want to? AddToFilter() and Recast.
However there’s not currently a method for removing items from the filter, which would help a lot when using Whitelists or if I want a different raycast before synchronizing to hit the part I just added to the filter.
I hate to argue with Roblox staff on this one, but unfortunately that viewpoint doesn’t seem to consider all the use-cases for parallel casting.
My use-case is raycasting for bullets mid-flight. I have a table of active bullets I’m checking in parallel. When it’s a bullet’s turn to perform a raycast check, I simply raycast, makes sense. I also have bullet penetration, so when a bullet hits someone, it logs the hit, and adds them to the ignorelist so a second cast can see who or what is behind them.
That’s great if one bullet was fired. But there’s usually multiple bullets in flight at any given time, and I can’t have all the bullets ignore that player, simply because one of the bullets already hit them.
Ah, so in your use case you have a base set of stuff to ignore which all the bullets use and then per-bullet a few additional things it passed through?
Also if you have a more efficient suggestion for handling it that doesn’t require a feature request I’d love the input, I’ve been really racking my brain trying to get around this particular issue.
Yeah, that use case is a bit unfortunate. The fastest existing approach is probably to create N RaycastParams assigning FilterDescendantsInstances = sharedIgnore for N bullets first in the serial section and then add the additional entries in the parallel section.