- Home /
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 https://media.giphy.com/media/l0IyhG7WQ5W96CHWU/giphy.gif
Answer by Razziel · Jun 20, 2017 at 09:37 AM
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.
Your answer
Follow this Question
Related Questions
how to rotate 2d obj on android 1 Answer
(2D) How to make kinematic rigidbodies rotate without clipping? 1 Answer
how do I make a joint that fixates the objects distance but lets them rotate freely? 1 Answer
Its this possible? 1 Answer
[Help] Object flips around when using transform.Rotate 3 Answers