Search Unity

About the way mass works with joints and rigidbodies.

Discussion in 'Physics' started by KristoE, Apr 10, 2016.

  1. KristoE

    KristoE

    Joined:
    Oct 13, 2012
    Posts:
    90
    I don't really have a clear question or a huge problem as such, rather just trying to better understand the way the physics work in Unity.

    I am using hinge joints to create a rope in 2D physics (1 end attached to a kinematic rigidbody and the other to a non-kinematic object that swings from the rope) and the issue I am having is that I don't want the rope to affect the physics of the hanging object too much, for example, when the object is on a ledge, with a rope attached to it, the gravity affecting the links in the rope would generate enough force to pull the object off of the ledge, which I'd prefer not to happen.

    The obvious solution here would be to either increase the mass of the hanging object or decrease the mass of the rope links. But when I go too far doing either of those, the physics start breaking and the rope will stretch out even though it should be limited from doing so by hinge joints. I'm guessing this is because the force that the hinge joints have on the hanging object is dependent on the mass they have.

    Is there maybe a clever way around this issue, maybe some way to give the joints more power when taken to the extremes?

    It is not currently a mayor issue for my game, as I have found a balance where it works quite well, but it is a subject I would like to understand more about to improve the physics in my future games and I think it should be a fun topic to discuss with other devs.

    So, have any of you run into a similar issue before and what would you think might be a good solution?
     
  2. KristoE

    KristoE

    Joined:
    Oct 13, 2012
    Posts:
    90
    Well, don't I feel silly and stupid now. Just as I finished writing this post, the way I worded one of the possible solutions made me think of a way to try and fix it.....

    ...and guess what, it worked like a charm and it is so super simple.

    Just in case you are wondering...

    I just added on another distance joint that limits the hanging objects maximum distance from the kinematic rigidbody that the first link of the rope is attached to.
    So basically, the heavy lifting is actually done by the single distance joint and the rope dangling between the 2 objects mostly only has the visual value as I set the mass of the links to a ridiculously low value.

    The KISS principle at it's finest I would say.

    If any of you have problems with the similar issue and my method is unclear, just ask.