BasePart :GetTouchingParts() and :IsTouching(Instance BasePart)

I would like to propose two new methods for BaseParts to help speed up the development process and expand what we are currently able to do. These methods allow us to check if two parts are intersecting and get a table of all the parts that are intersecting.

Table BasePart:GetTouchingParts() would be a method that returns all part that the BasePart is in contact with. This would include anchored parts that share the same face as a BasePart but perhaps aren’t connected as well as any part that might have fired the touched event (regardless of any event listeners.) An example of usage might be a tower, if you destroy the bottom of the tower you want the whole tower to fall, therefore you can find the parts that it’s connected to and make them fall with it.

Boolean BasePart:IsTouching(Instance BasePart) would be a method that returns true or false depending on whether or not two parts are intersecting/touching. An example of usage might be in a racing game, you want to predict when two cars will collide so you add larger hit boxes to them and check if they’re colliding to warn players they are about to crash into another player.

Both these methods can be produced using Lua, but both are quite difficult for novice programmers to create unless they have a good understanding of mathematics. The second is also already hard coded in the physics engine and really it’s just a case of exposing that for use with Lua.

2 Likes

I wanted to add a command to Numonji’s command panel to select touching parts – this would be wonderful for that. There will always be something we wish to exclude though (e.g. the baseplate, terrain, the floor to a building if we just want to select a complex lamp, etc), so there should be a table ignore list for both methods.

[quote] I wanted to add a command to Numonji’s command panel to select touching parts – this would be wonderful for that. There will always be something we wish to exclude though (e.g. the baseplate, terrain, the floor to a building if we just want to select a complex lamp, etc), so there should be a table ignore list for both methods. [/quote]The second you wouldn’t possibly need an ignore list for, you’re comparing two known parts. The first, you could do it yourself, but it might be a good addition.

This is actually partially included in an upcoming release - here’s a line from GT1 API dump:

Function Objects BasePart:GetTouchingParts()

[quote] This is actually partially included in an upcoming release - here’s a line from GT1 API dump:

Function Objects BasePart:GetTouchingParts() [/quote]Would you be open to considering the latter? I'm really glad to hear this, but I think the latter is equally important.  :woohoo:

[quote] This is actually partially included in an upcoming release - here’s a line from GT1 API dump:

Function Objects BasePart:GetTouchingParts() [/quote]

Ignore list as parameter pls :frowning:

[quote] This is actually partially included in an upcoming release - here’s a line from GT1 API dump:

Function Objects BasePart:GetTouchingParts()  [/quote]

Ignore list as parameter pls :([/quote]

Use a manual ignore list?

"Use a manual ignore list? "

How2?

[quote] "Use a manual ignore list? "

How2? [/quote]

foreach connected part
if not part is in ignore list then
do stuff
end if
end foreach

Oh wait – I’m understood this wrong. I was thinking it would be recursive like this:

If it’s just the parts currently touching the given part and not recursive, that works too and I can make it recursive with an ignore list on my own. Question though: Would these be considered touching, or is it really a :GetIntersectingParts() type of deal?