After updating from Unity 5.3 to Unity 5.5 hinge joints started getting weird offsets.

I have a simple 2D ragdoll made by connecting a head with a body and four limbs through hinge joint 2Ds. This worked pretty well in Unity 5.3, but now I updated to Unity 5.5. and things started acting pretty weirdly. After tempering just a little bit with the character in-game, one or two of the limbs end up totally separate from the body. And I don’t mean that the hinge would break as in being totally detached from the main body, they just are far away from the body. So the human equivalent would be a person walking around so that his/her hand would be following flying in the air 3 meters away.

Any idea what could be causing this? I took a quick look at the change logs for Unity 5.4 and Unity 5.5, but if the reason is eg. “Physics engine updated from PhysX 3.3.1 to PhysX 3.3.3.”, then it’s really hard to know what the exact reason for things breaking up is.

Did you make any progress on this? After upgrading to 5.5.0 we are seeing the same symptoms which is completely breaking our game. :frowning:

I think I managed to fix it.

I replaced

X.isKinematic = false with X.bodyType = RigidbodyType2D.Dynamic
and
X.isKinematic = true with X.bodyType = RigidbodyType2D.Static

And my game is back to its original behavior.

The above doesn’t really make sense. IsKinematic has been left in for backwards compatibility for now but it still works and just set the body-type.

Using X.isKinematic = true simply sets the X.bodyType to RigidbodyType2D.Kinematic, likewise when set to false then X.bodyType it se to RigidbodyType2D.Dynamic.

You stated you changed your code to set the body type to RigidbodyType2D.Static when setting the X.IsKinematic = true which should been obviously wrong.

Yeah, I did. I just didn’t want to bump the thread up, as no one had replied to it, and I don’t really have a clear answer for what exactly was wrong. In any case restructuring how the objects are parented seemed to fix the issue.

I’m still of course a bit curious as to what changed with the physics handling between 5.3 and 5.5. There were two problem-causing differences I encountered with the upgrade related to physics. The other one was that apparently with the older version just setting body.isKinematic = true earlier also set the velocities to 0, but now they had to be separately set to 0 (which actually does make more sense). That was quickly found and fixed, but the way the hinge joints didn’t any more hold properly was and still feels weird.

One thing that comes to mind is that we recently fixed a bug which I believe was introduced into 5.5 where if the body-type (or IsKinematic) is being constantly set to the same value then contacts were being recalculated which caused subtle instabilities. Maybe you are experiencing this.

Always best to avoid changing physics object properties if they can be avoided.

I don’t think that’s it. I’m not constantly setting the bodytype. The very simple reason for changing the state is having the ability to pause the game. :slight_smile:

You’re changing the body state to pause it? That’s an expensive way of doing things. If you want to stop the simulation on a body then simply use Rigidbody2D.simulated which is extremely cheap and also affects all attached joints and effectors etc.

1 Like

Ok. Thanks for the tip! While I was writing I was thinking that maybe there is actually a better way, like using the sleeping setting, but that’s probably the wrong way, as that’s for optimization. I’ll try the simulated setting.

ed: ok, tried it. Sweet, now storing and restoring the velocities isn’t needed any more either. :slight_smile:

1 Like