Creating a ray that automatically ignores transparent parts

unless theres parts within that transparent part (as children) then the descendants of that model will not be ignored

Here’s what I mean

in this case the non transparent part will NOT be ignored by the ray

BUT


in this case the non transparent part WILL be ignored by the ray (as its a descendant of the part)

There aren’t transparent children in the object, there is one part over shadowing another part, is there a way to for the ray to go through the part without needing to cast another ray entirely?

if the part has no descendants then the IgnoreDescendantsList solution is the way to go, it does NOT cast multiple rays!

There is a part in front of another part, not in models, descendants, children there are two parts in workspace one is over shadowing another, is there a way to cast one ray that goes through that part?

See, did you read my reply at the top, it’s just in front not inside a model, etc

Please read it carefully.

Don’t know if anyone has mentioned this yet, but you can set the transparent parts to a different collision group.
Then set the ray to a separate collision group by using RaycastParams.CollisionGroup, and this group has collisions turned off with the transparent parts collision group.

9 Likes

you’re not understanding what Im trying to say. If you set the IgnoreDescendantsList to that part (or all transparent ones, your choice)
then the ray will go THROUGH that part by default, it will ignore it, you have to do nothing else than assigning IgnoreDescendantsList appropriately.

No matter if its inside the model or outside it will be ignored and the ray will go through.

you should give this a quick read

Thank you, see they get what I’m saying.

So set the transparent part collision group to something different I.e 2, and set the rays collision group to something higher?

Yes, I know that, but when it’s added to the filter i need to cast another ray, because the first ray has already hit something. That’s how you got the transparent object, in the first place.

no you dont, the ray will NOT hit that part at all (if you set the filter BEFORE casting the ray which is how it should be done in all cases)…
the ray will continue moving as if that part never existed

It doesn’t matter what order the collision grouping is, just simply uncheck the box where the racyast and transparent part collision groups meets.
image
In this image, both “raycast” and “thin” will collide with the default collision group, but won’t collide with each other

2 Likes

I can’t set it before because, theoretically the part could still be there or it be gone. Do you feel me?!

ray casts are instantaneous, the chance that the part will be deleted/created while the ray is being cast is negligible so you should be fine. The collision group method also works

Thanks, this is exactly what I’ve been looking for. And it was a more comprehensible solution that I thought.

THANK YOU :+1:

Not deleted while the ray is casting, I mean if the part doesn’t exist. There is nothing to add to the filter, but it’s fine, I’ve got the solution provided by @amadeupworld2

1 Like

The new easy way to make the RayCast go through an invisible part is by disabling the “CanQuery” property of the part.