BasePart:GetTouchingParts() for any parts, not just CanCollide true

As a developer, I find it’s too complicated to find what parts are intersecting an area or another part. The :GetTouchingParts() function seemed to look like it would solve it - except it’s just for CanCollide true parts??

It’d be really handy if there was either an option for this function to include CanCollide false parts, or to make a separate function which would do the same thing. I know I could make rotated Region3s, but it just seems like it’s overcomplicating a simple issue - though as far as I know, it’s the only solution to this.

Also, please tell me if I’m wrong and if there is already a simple way to do this. I tried using .Touched and .TouchEnded but that can get messy and buggy, so that isn’t a very practical solution either.

9 Likes

I did this to fix this problem a while ago:

  • Do a Region3 check on a world-axis-oriented bounding box that contains the volume you’re checking for
  • Get all non-CanCollide parts in this Region3
  • Set them all temporarily to CanCollide = true
  • Immediately do the GetTouchingParts check
  • Set all parts that were modified back to CanCollide = false

This won’t affect physics or anything since it all happens without yielding inbetween.

Although, it would be convenient if it just picked up on CanCollide=false parts as a parameter of the method. People may be relying on the fact that it doesn’t pick up on CanCollide=false parts right now, so I think it should be an option.

For my problem I actually ended up using the rotated region3 module - it’s much easier than I thought initially. I still think this would be convenient though, I’d rather not go through longer measures to just be able to get the parts intersecting another part. I’ll see if your solution is faster though.

1 Like

I use the same method as buildthomas.
However, setting non-CC parts CC on and off is not preferable sometimes and it would indeed be a helpful addition to this method without having to go trough the trouble of using Region3.

1 Like

Since that post, I found that this method is much easier:

It does not discredit the feature request, but that workaround is quite useful.

7 Likes