Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Strange rigidbody behaviour when center of mass is offset from pivot

Discussion in 'Physics' started by Dizzy-Dalvin, May 18, 2016.

  1. Dizzy-Dalvin

    Dizzy-Dalvin

    Joined:
    Jul 4, 2013
    Posts:
    54
    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.
     

    Attached Files:

  2. alexzzzz

    alexzzzz

    Joined:
    Nov 20, 2010
    Posts:
    1,447
    Looks like a bug. Send the bug report.
     
  3. Dizzy-Dalvin

    Dizzy-Dalvin

    Joined:
    Jul 4, 2013
    Posts:
    54
    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.
     
  4. alexzzzz

    alexzzzz

    Joined:
    Nov 20, 2010
    Posts:
    1,447
    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.
     
  5. Dizzy-Dalvin

    Dizzy-Dalvin

    Joined:
    Jul 4, 2013
    Posts:
    54
    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.
     
  6. sarebots2

    sarebots2

    Joined:
    Jul 4, 2016
    Posts:
    34
    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?
     
  7. Dizzy-Dalvin

    Dizzy-Dalvin

    Joined:
    Jul 4, 2013
    Posts:
    54
    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.
     
  8. DerrickMoore

    DerrickMoore

    Joined:
    Feb 4, 2018
    Posts:
    246
    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
     
  9. pheckinger

    pheckinger

    Joined:
    Jan 24, 2022
    Posts:
    5
    This is an old thread, but the bug is still happening in unity 2020 (and its the year 2022 right now)
    :(