Angular torque and velocity on different children of same parent

This is my 3d object.

  |-- Body
  |-- Label

Body is a 3d capsule Label is a text field

I want this object to hang around in space and get knocked away when something collides with it. But i want the whole object, Target, to move away from the collision with the normal physical simulation. I dont want the body to move in its local space. However the rotational force (angular torque) should only affect the Body and not the Target object which always should have a rotation of 0,0,0 not to affect the Label and other children of Target.

This should be a quite normal situation but i cant remember seen any typical solution for it. How is this normally done?

1 answer

  • answered 2018-03-20 15:59 avariant

    To expand on my comment regarding separating Body from Target and placing Target under manual control, I imagine it would look like this:

    |-- Label
    |-- Others
    Body >> RigidBody

    Then implement a script something like this on Target

    public class Follow: MonoBehavior
        //This would likely be 'Body'
        public Transform Attached = null;
        //This is the offset you want Target, Label, etc. to be from Body
        public Vector3 Offset = new Vector3(10, 10, 10);
        //Fixed Update is preferred when responding to physical simulation
        void FixedUpdate()
            if (Attached != null) transform.position = Attached.position + Offset;