2
\$\begingroup\$

I have added a rope to my game that is made up of multiple small gameobjects, each connected to eachother by a HingeJoint2D. Since 1 unit of mass in Unity is supposed to represent 1 kg, I've made the player's mass 60 (60kg). When the mass of each rope segment (of which there are 40) is 20, the rope supports the player when they jump off a cliff.

enter image description here

Now 20 kg per rope segment sounds ludicrous. However when I make each rope segment weigh 1 (1kg) the hingejoints break completely and jitter around crazily. The force of the 60kg player against the 1kg segments seems to be too much.

enter image description here

I would much rather have the rope be lighter, so it doesn't move the player when throwing and being dragged as much. Any suggestions on how to fix HingeJoint2D's and make them act, as you know, a joint should?

EDIT: Increasing the Position and Velocity Iterations in File->Project->Physics2D menu from the default 3 and 9 respectively, up to a whopping 40 fixes this problem. This is a massive increase. Unsure if performance will suffer too much with these new settings.

\$\endgroup\$
1
\$\begingroup\$

Yes, they do; all joints do. And there is no (realistic) solution as fas as i know.

I read somewhere in documentation that says two objects connected with a joint should have close masses. It's too weird, actually.

I encourage you to use good old parent-child technique; never breaks, never acts oddly, and never extends (or reverse) like your second image.

\$\endgroup\$
2
  • \$\begingroup\$ Thanks for your answer. I don't know why joints just couldn't be some magical substance that ignores mass. Could you explain this parent-child technique? I know that when you move a parent the children move as well. How could this be applied to make a physics based rope? \$\endgroup\$
    – DeeCeptor
    Dec 5 '15 at 18:55
  • \$\begingroup\$ @DeeCeptor It has nothing to do with parenting, but you fake parenting by scripts. Lets assume we have 3 segments of rope named A B and C (in that order). They all will have seperate rigidbodies and will be on the same level in hierarchy. Then you put B to the end of A, then set the centerOfMass of the rigidbody of B to the end point of A. And do the same thing for C, while taking B as referance. And within your scripts, you need to manually move segments to create a fake parent-child effect - a script to move C's beginning to B's ending and B's beginning to A's ending. \$\endgroup\$ Dec 5 '15 at 19:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.