Hello. I am wondering if there is any function which is similar to GetTouchingParts(), a method of BaseParts, without having to actually instantiate any basepart to use. I have attempted to use Region3 checks, but have found that for my usage (mapping traversable regions for pathfinding in a octree) it is simply far too inaccurate because the collision detection is not exact.
What? you want to know if there is anything equivalent of BasePart:GetTouchingParts()
without there having to be a BasePart?
Yes. Using BasePart:GetTouchingParts()
seems to be a little hacky for what I want to do, and slow too.
It sounds like you want to figure out if a basepart is within a region. If that is the case, writing your own custom algorithm to detect such a thing would be enormously and unnecessarily complex (because baseparts can be multiple different shapes, and even in the simplest case of a brick, you would need to do an oriented bounding box (OBB) to OBB intersection test – that is, if you were looking for a mathematical solution to this problem).
If all you care about is whether the center of a basepart is within your defined region, then the problem is a lot simpler and can be done with a simple point - oriented bounding box test; you can google to figure out a very simple algorithm to test that. Requires a little bit of geometry and vector math but nothing crazy (since you mentioned quadtrees, I assume you are at least a little familiar).
If writing math isn’t what you are looking for, realistically your best option is to make use of Roblox’s excellent physics collision system (not being sarcastic, it really works). BasePart:GetTouchingParts() is the cleanest solution and I can’t see why you wouldn’t use it, but if not, an alternative could be to listen to the Touched and TouchEnded events of an uncancollided part and keep a running tab of what is within the region.
…or you can use one of those Rotated Region3 modules that people have written. Search it up here on the devforum.
Thanks, I’ll try have a poke around with a few of the methods you have described.
Sure, the method itself is a clean solution, but I’m not really sure I want to create a part just for the purpose of checking if other things are in a specified region, changing its position + size potentially hundreds of times within a single frame to do this. To me, it seems an improper approach.