rotate object that has FixedJoint2D

Hello, I have an in-game Editor that allows creation of different machines. I was using RelativeJoint2D so far in order to “glue” pieces together. But that has proven to fail, since the machine was starting to bounce all over the place when adding multiple glued parts.

This in-game editor makes all current parts of the machine kinematic in order to move/rotate them.
While kinematic, when i rotate an object that has a fixed joint, it maintains the rotation, but when i play the simulation (making the machine non-kinematic) it switches back to the original, before making the object kinematic, rotation.

You can see this behaviour in the gif below

So i have found a way, but it’s a little bit of cheating. Everytime i want to rotate the fixedJoint, i destroy it and then i add it again with the same properties.

Rigidbody2D rb = joint.connectedBody; Destroy(joint); joint = gameObject.AddComponent<FixedJoint2D>(); joint.connectedBody = rb;

This makes a new fixedJoint2D that will have the new rotation.