Joint reset problem

Hi,

I’m working on a project where the user must be able to position and rotate furnitures in a room. Right now, I’ve got the positioning working fine by using a modified version of the DragRigidbody script (SpringJoint-based control). In order to prevent the dragged object from rotating while being moved around, I add a ConfigurableJoint on the object with XYZ rotation locked, and vertical translation locked too.

So this works fine for translating objects via a SpringJoint control. Now, I also want the user to be able to rotate this object. When rotation mode is enabled, the object to rotate should not move - the object should be “pinned down” and only rotate due to the SprintJoint moving around. In order to accomplish this, I tried to lock the XYZ motion on the ConfigurableJoint of the object, and unlock AngularYMotion.

This works until I go back to “Translation” mode and move the object around. When I do that, the object’s rotation resets to its default instead of keeping the new orientation setup by the user. It seems that the act of modifying the Angular motion constraint at runtime causes the object’s rotation to “reset” to an internal default angle.

I’m curious as to what’s causing this, and how I can work around it.
Any help/ideas on how to solve this would be very appreciated!
Thanks.

Bumping, as it’s kinda urgent!

The rotation that the object has when the joint is created is the one used for the locking. I think you should be able to fix this by destroying the existing joint and then creating a new one and setting the rotation locking.

Cheers, I was about to try that but I was wondering if there was a cleaner/better way of achieving this… looks like not.

1 Like