Search Unity

  1. Check out the Unite LA keynote for updates on the Visual Effect Editor, the FPS Sample, ECS, Unity for Film and more! Watch it now!
    Dismiss Notice
  2. The Unity Pro & Visual Studio Professional Bundle gives you the tools you need to develop faster & collaborate more efficiently. Learn more.
    Dismiss Notice
  3. Improved Prefab workflow (includes Nested Prefabs!), 2D isometric Tilemap and more! Get the 2018.3 Beta now.
    Dismiss Notice
  4. Improve your Unity skills with a certified instructor in a private, interactive classroom. Watch the overview now.
    Dismiss Notice
  5. Want to see the most recent patch releases? Take a peek at the patch release page.
    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:
    42
    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,353
    Looks like a bug. Send the bug report.
     
  3. Dizzy-Dalvin

    Dizzy-Dalvin

    Joined:
    Jul 4, 2013
    Posts:
    42
    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,353
    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:
    42
    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:
    10
    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:
    42
    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:
    206
    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