"BasePart:GetTouchingParts()" bugs might be directly related to physics setting "allow sleep"?

I’ve been playing around with “BasePart:GetTouchingParts()” for some time now and I just stumbled upon its irregularities/bugs where it doesn’t register touching parts. After some testing I figured that it might be related to Studio physics performance setting “Allow sleep” as after multiple tests of keeping the setting set to true the part didn’t detect another part touching it but as soon as i turned the setting off, the results were correct.

Environment setting:

  • Part_1 (Below part) rests on baseplate
  • Part_2 (Above part) falls on top of Part_1 in a slightly offset position (not directly on top)

Every second this script is performed:

print("Above part: ", Part_2:GetTouchingParts())
print("Below part: ", Part_1:GetTouchingParts())

small notes:

  • Part_1 is identical to Part_2
  • Both of the parts are flat (8; 1; 8) pieces

Expectation:
When Part_2 falls and rests on top of Part_1,

print("Above part: ", Part_2:GetTouchingParts())
print("Below part: ", Part_1:GetTouchingParts()) 

will give a result of:

Above part:  ▼  {
[1] = Part_1
}
Below part:   ▼  {
[1] = Baseplate
[2] = Part_2
}

Actual results:
When Part_2 hits Part_1, the results are exactly as expected but approximately, after Part_2 sets in place and stops moving, I get this:

Above part: {}
Below part:   ▼  {
[1] = Baseplate
}

This method as well as GetPartsInPart() doesn’t bring back expected correct results. This happens when ‘allow sleep’ is set to true. When it is set to false, every test that I did, the results come back correct.
BUT when I moved the whole part setup by a few studs to the right and tested multiple times, the results were correct even with “allow sleep” on and remained the same.

Hypothesis:
In that one specific situation as soon as Part_2 rested on top of Part_1 and entered the sleep state, it somehow stopped interacting with Part_1 and both methods just somehow failed to register part interactions. I just fail to realize, what kind of influence the position change had, because as soon as I moved the whole setup to the right (didn’t change part position Y’s (height)), the results were correct even with “allow sleep”.

Summary:
This is clearly EITHER a still existing bug in some specific conditions and the only way to avoid it is to turn off “allow sleep” which WILL have an impact on performance OR i don’t have enough knowledge on how to properly execute the methods.

In any way, it is mostly clear that BasePart:GetTouchingParts() and GetPartsInPart() still has bugs but it might be directly related to “allow sleep” physics setting. I hope that people will notice this and hopefully have some thoughts, notices or help. This might be the key issue to address and completely solve bugs of the said methods.

2 Likes