Two Fixed Joints attached to parent, parent Hinged to another body, everything goes insane.


I have a game object called “Pants”.
Then I have 2 objects attached to it: LegLeft, LegRight.
I want the objects to behave separately.
I have attached the LegLeft and LegRight to the GameObject ‘Pants’, each with a Fixed Joint. Their parent has only a RigidBody.

The parent object ‘Pants’ gets attached to another object at a distance using a Hinge. This is where the LegRight and LegLeft go insane, start sliding upon the relative Y axis until they fling out of control in the span of 2 seconds.

This is fixed by changing the Fixed Joint on LegRight to be attached to LegLeft. That way, LegRight is attached to LegLeft using a Fixed Joint, then Leg Left is attached to the Pants using a Fixed Joint, and the Pants are attached with a Hinge to another object. But I am noticing a drop in performance that I am unable to diagnose using the Profiler.

Why doesn’t it work when both LegRight and LegLeft are both attached to the parent with a fixed joint? What make them go insane?

There are no colliders involved, and the project is 2D.

Wheel Joint instead of Hinge Joint on the parent to the other object seems to fix it.
It is also fixed by adding Box Colliders 2D on the LegRight and LegLeft objects.
Still looking for an explanation. Maybe the Hinge is trying to rotate the legs into a certain position to act like a hinge, but then the Fixed Joints prevent that, but it would make no sense why adding Box Colliders would fix that.

Adding colliders change the rotational inertia. Also, you are free to increase the number of velocity iterations allowed in 2D physics settings as the default of 8 may be too few for a complex set-up of joints. It’ll not always use that many iterations but it’ll use up to that limit when trying to solve joints and finish when it’s satisfied.