Having children rigidbodies rotate with parent rigidbody.


‘P’ square is the parent rigidbody. ‘C’ circles are the children rigidbodies. They are connected via configurable joints and the children have some freedom to move relative to the parent. In general they behave like I want them to (sort of like springs), so I don’t want to change up the setup etc.

I want the user to be able to press a key and have a rotational force applied to the entire object (parent and children) as a whole. I have it now where the parent object is rotated, having the children catch up (it works, but not as well as I’d like) – I’d like to have it where it’s like rotating the object as a whole so that the children don’t lag behind. What can I do?

Would it be possible to link the transforms of the parent and children onto a temporary ‘rotation’ object? Not sure how this would affect the physics.

Something like this -

gameobject rotationObject;
parent.transform.parent = rotationObject;
child1.transform.parent = rotationObject;
child2.transform.parent = rotationObject;

rotationObject.transform.rotate;

//Set things back as they were.

This is my doubt too, i can’t understand how this parent works.

Coming back to this problem –

I considered something like this, but I’m not sure how it’d work. The children are rigidbodies, so I’d have to set them to kinematic for them to rotate like you suggest, ,right? As far as I know, going to and from isKinematic isn’t really going to get me smooth physics results.

edit: perhaps instead, i can temporarily ‘freeze’ the configurable joints during the frame I apply torque? Going to try this…

edit2: yeah, didn’t really help. Doing it all in one frame makes little or no difference. Yielding a frame before unfreezing creates odd behavior. I think the problem is that when you lock it, it resets to the default position instead of locking it at whatever position it is at currently.

Made an Answers entry… http://answers.unity3d.com/questions/38337/in-script-how-to-set-configurablejointmotion-to-locked-without-it-reseting-to-de