2 specific parts overlapping?

Hi! My mind has once again reached a blank, and I have no idea how to do this, and can’t seem to find any related posts.

What I want to do is find 2 overlapping parts without using regions, or the FindPart methods in workspace that return tables. This is because when using GetPartsInPart or similar with larger parts that cover a large area (such as a city), they return massive tables full of instances and they seem to be causing memory problems for the game (it’s quite a large game).

What I’m looking for is essentially a function that detects if part A (HumanoidRootPart) is inside part B (Big Region Part) and returns true or false without checking EVERY part that’s touching it. I can imagine the vector maths for calculating this is fairly simple but I’m no good with Vector maths and can’t seem to think how to do this.

If anyone has any resources, references or anything that would help it’d be greatly appreciated! Again, apologies for my stupidity, and sorry if this has already been talked about!

Why not flip the PartsInPart method around and call it on the root part?

If you convert part A’s position into the object space of part B, its coordinates will start at B’s origin and have the same orientation. Then, if that vector is inside the bounds +/- Size/2, A is inside B. This doesn’t account for rotation of A, which may be fine if B is much larger than A. It checks if A’s origin is inside B.

I’m so thick, this didn’t even cross my mind. :sweat_smile:

Thank you!

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.