There are a couple of rigidbodies touching each other and/or the static ground. All the bodies are, most likely, sleeping. The problem I’m trying to solve is the following:
There’s an object the player wants to move, let’s call it a platform, and there may be other objects touching the platform. Those that touch only the platform should be moved with it like children (the pair of cubes on the picture). Those that also touch something else (like the plank that touches the platform and the ground) shouldn’t be moved with the platform.
OnCollisionStay() has all the information I need, but sleeping bodies don’t receive such a message.
In order to get this message for the platform I have to
- wake up all the bodies around it,
- prevent them from sleeping for a while,
- shake them a little to generate new collisions (because it looks like the old collision information gets lost when the body falls asleep).
This doesn’t look like a sound solution at all.
PS
The objects may be simple boxes or convex meshes or complex compound bodies with dozens of parts.
PPS
Rigidbody.SweepTestAll doesn’t return bodies that are touching the current one already. Besides, it doesn’t support convex mesh colliders.