In our game we build a complex object with a lot of colliders (thus creating a compound collider), then add rigidbody component to it. When it drops to the ground very often it starts bouncing really strange. After a lot of investigation we’ve found out that it’s caused by the center of mass (which is calculated by Unity correctly) and happens even on a single collider. When center of mass is far from rigidbody pivot position, as in our case, it behaves this way. When we move inner objects so that their center of mass is approximately at the same position as parent pivot, the bug goes away.
I’ve created and attached a simple test project to illustrate the issue: open the Main Scene, hit Play, then select the right cube and press Drop on RBGizmos script. It starts bouncing like crazy 80% of the time.
Even strangely, when tested in 5.4 beta it just falls through the ground every time.
2639974–185801–CenterOfMassTest.zip (31.4 KB)
Looks like a bug. Send the bug report.
Yes, I’ve filed a bug report after posting this, and they’ve already responded that yes, it’s probably a bug and that they’ll see into it.
It’s strange that I couldn’t find another thread about this problem, since it is reproduced so easily.
Now, after I’ve seen your repro project, I remember that I’ve already experienced something similar. I use procedurally generated geometry. There was a bug in my project so that some rigidbodies had displaced pivots - far outside of the geometry and far away from the center of mass. I just fixed the bug in my project and forgot about this issue.
I could line up pivots and that would fix the issue, but since it’s a complex object with parts being added and removed quite often I’ll have to recalculate inner objects’ positions all the time. What’s even worse, we use a pool system so I’ll have to store and reset these modifications. All in all, this would only complicate things and introduce more bugs, while center of mass should be enough and it should be working already.
I know this is 2 years old, but I found the same bug in my Unity 2018.2 project. Did you find any fix for it?
No, I heard from Unity that it’s supposed to be fixed when they upgrade PhysX to a new version. Guess it’s not there yet. In the end, we had to introduce and maintain offsets through code.
hmm… object is bouncing wildly… check to see if you have Collision boxes that are intersecting… colliding with each other, but cant move cause they are kinematic or attached or something
This is an old thread, but the bug is still happening in unity 2020 (and its the year 2022 right now)