Search Unity

  1. The 2022.1 beta is now available for testing. To find out what's new, have a look at our 2022.1 beta blog post.
    Dismiss Notice

Collider affects hinge joint

Discussion in 'Editor & General Support' started by adamjamescuz, Oct 29, 2012.

  1. adamjamescuz


    Oct 29, 2012

    I am making a chain of gameobjects using hinge joints, each gameobject needs to have a collider on it. If I set the 'isTrigger' property of the collider to true the chain acts exactly how I want, i.e nice an taught like a rubber band. With 'isTrigger' set off the chain is loose and saggy. I need to have the collider on it with 'isTrigger' set off so different chains can collide with each other - does anyone know why this is / a possible to solution to overcome this? It seems the collider is adding to each game objects mass or something.

    Many thanks
  2. QuantumRyan


    Aug 30, 2011
    paternostrox likes this.
  3. fek


    Sep 14, 2015
    I, too, feel obligated to bump this even though it's an older thread, because it took me forever to find, and it ended up being the answer to a problem I've been struggling with for months.

    I'll try to explain my bug, so it shows up better in search results for future users.

    I'm building a character editor, and many of the characters have tails. In their tails, I have a chain of rigidbodies connected via characterjoints. I wanted some of the characters to have tails that were loose and floppy, and others to have tails that were stiff and rigid. I attempted to do this by adjusting the swing limits and spring values, but no matter what values I used, I would encounter these problems:
    • The colliders would jitter, as if they were colliding with each other or some other colliders elsewhere in the character and then failing to resolve elegantly with projection. I thought that perhaps Physics.ignorelayercollision wasn't working, but when I traced out collision events, it confirmed that there really weren't any collisions happening.
    • No matter how high I set the spring values, I simply couldn't get the chain of rigidbodies to stay stiff / erect. The tail was always floppy, even with absurdly high spring values and extremely low swing limits.
    • When I changed the colliders to have .isTrigger = true, everything worked perfectly (except now there was no more collision, of course). But if I simply disabled the colliders, or even removed the collider components completely, it did not work as expected. It seemed that simply CREATING the colliders was all it took to ruin the tail physics, even if I consequently removed the colliders entirely.
    I was absolutely certain that there was some sort of collision bug happening somewhere, and just as I was getting exasperated, I stumbled upon this thread. I decided to trace out my Rigidbodies' .centerOfMass values to see if they were different when I toggled .isTrigger on and off, and sure enough, they were.

    The solution, for anyone else who finds themselves in a situation like mine, is extremely simple:

    You need to manually set every one of your Rigidbody components to have a .centerOfMass of [0,0,0]

    I made it the very first line of code after creating the Rigidbody, before I create or attach any colliders to it. Now, there is no noticable difference between the behavior of my character tails whether they're set to be triggers or not, except that collisions work properly.
    Last edited: Feb 19, 2017
  4. fek


    Sep 14, 2015
    After upgrading from Unity 5.2 to 5.4, the solution I explained above no longer works. I'm in the process of trying to find out why.

    Rage-inducing. It would be so nice if I could just add a collider to an object that's already behaving exactly how I want it, without it absolutely wrecking all of that object's behavior.
    GHOSTO00 likes this.
  5. fek


    Sep 14, 2015
    Turns out there's yet another variable that gets automatically calculated when you add a Collider, and if you don't manually reset it back to your desired value, it screws up your physics.

    The variable is RigidBody.inertiaTensor, and it seems like the "default" value (or at least the one that works for me) is Vector3.One (1,1,1).
    ZapperCZ, crico-jp, GHOSTO00 and 5 others like this.
  6. DavidErosa


    Aug 30, 2012
    On 5.5.0f3, @fek solution is still needed and valid... Thanks a lot!
    crico-jp likes this.
  7. Andresmonte


    Nov 22, 2014
    Small colliders also cause this problem, do what is said is this thread solves the problem
  8. Michcio174


    Mar 14, 2015
    Bumping this thread as it is hard to find but contains insanely useful information.

    I wanted to make a robotic arm in Unity 5.6 (a truck-mounted crane to be precise) using configurable joints. They were very wobbly. The crane consisted of several joints and parts. And even though all rotation axes except the desired one were locked, the parts were spinning a bit in locked directions as a result of drag and inertia. It was causing unrealistic vibrations at best and making the simulator look ridiculous and uncontrollable at worst. Finally I discovered that wide colliders helped somewhat, but they were not an option as crane would collide with other geometry in the scene.

    It turnus out that using RigidBody.inertiaTensor those joints can be stabilized even when no collider is attached to the joined rigidbodies. Just set it to some large values like (50,50,50). Thank you a lot, fek. I was having problems with that for weeks and I had no idea that parameter existed!
  9. CanadianGuy43


    Feb 3, 2013
    This is still an issue as of Unity 2017.1.1.

    For those of you using Rigidbody2D, setup the rigidbody like so:
    Rigidbody2D.centerOfMass =;
    Rigidbody2D.inertia = 1.0f;
  10. Ldnicon


    May 22, 2016
    This is still an issue in Unity 2018.2.8f1

    Still working:
    Code (CSharp):
    1. rb.centerOfMass = new Vector3(0,0,0);
    2. rb.inertiaTensor = new Vector3(1, 1, 1);
  11. vanhalen17


    Apr 19, 2015
    Confirmed bug still exists in 2019.3.1f6, confirmed this solution still solves the issue. Can't believe for 7 years devs have been hacking at this, all to put a collider on a hinge joint. What a sin! Unity should update their docs with this as a suggestion, or at least caution about the potential problem
  12. mpodlesny


    Jun 29, 2020
    Still doesn't work as of 8/16/2020 - tried the code work around above and that doesn't work either.
  13. ZapperCZ


    Jul 28, 2020
    Gonna add onto the pile of people experiencing this issue.

    Was having trouble while simulating tank tracks using hinge joints as they would end up jittering all over the place once more of the links were being moved, thankfully fek's solution worked for me in 2021.1.15f1