Reposition anchor of a world-attached joint

Hi. I'm trying to create a physics object which consists of several parts connected through joints.



One of the parts should be attached to the world, like a desk lamp with arms with the base is fixed on the desk.



I have a joint attached to the base part so that it is fixed to the world.



The problem is that I need to be able to reposition the lamp, without inflicting any forces on the rest of the lamp. I have tried setAnchor(newPosition) on the base joint but it wont move.



I also tried to setActive(false) on the joint before moving it and then setActive(true) again after, That will allow the lamp to be moved but afterward the base is not fixed to the world anymore.



How should I solve this?

Try calling joint.reset() after setAnchor(). This makes the joint revert to being in a "just created" state, should solve your problem.

Thank you,



I'm afraid that didn't work. The fixed joint still isn't fixed after joint.reset(), but when I tried to also reattach it to the DynamicPhysicsNode it worked.



The joint seems to loose it's attachment to the DynamicPhysicsNode when  called setActive(false) upon.

Rik said:

The joint seems to loose it's attachment to the DynamicPhysicsNode when  called setActive(false) upon.

Yes, that is desired behavior. The setActive() methods are the only way to remove physics objects from the space/scene. If you just want to move the anchor of a joint, you should only need the reset() method, not setActive(false) + setActive(true).

Glad its working for you!

Yep, that works too, Thanks again!