What could possibly be causing this Hingejoint2D issue?

Hey guys,

So I’ve been trying to solve this hingejoint2d issue for about 2 weeks now. I’ve asked the guys over at the subreddits and in IRC with no success.
Here’s a web build of my issue: https://dl.dropboxusercontent.com/u/49940637/Public.html (let it run for 2 spins)

Basically, the hingejoint2d connected to the main body goes crazy after the circle has done 2-3 full rotation and you then enable it. It doesn’t have to be a chain either, just one hinge is enough to make it go crazy.

You can reproduce this issue easily by creating a parent body, connect a child to it with a hingejoint2d which in turn is connected to the parent with a angle limit. Rotate the parent body and disable/enable the child. Voila, crazy ensues.

So far I’ve tried:

  • Zeroing-out all physics by doing Sleep, IsKinematic, etc.
  • Adding/Removing colliders on the parts as well as ignore colliders.
  • Manually zeroing out angularVelocity and velocity on the rigibody2d OnEnable();
  • Setting the hingejoint2d angle limit to it’s new jointAngle when OnEnable();
  • Setting the transform.localRotation to 0

Project can be downloaded here: Dropbox - Error - Simplify your life Unity 4.6.1f1

If anyone knows anything at all about this, has any tips or thoughts; please please let me know! For all I know I could be doing something very simple wrong.

Edit: Just tried on Unity 5.0 rc1 - Same issue there.

1 Like

I had the same problem, fixed only by destroying HingeJoint2D component on disable and adding it again on enable.
Seems like changing the position of parent body via Transform component causes this issue. Another way of doing this is rotating parent body by rigidbody2d.MoveRotation or AddTorque. Hope it helps.