- Home /
Question by
fzzr · Oct 14, 2010 at 09:34 PM ·
rotationrigidbodymeshcollidercenterofmassaddrelativetorque
centerOfMass and local coordinate origin
Is there a way to set the origin of the local coordinate system of a rigidbody
equal to the centerOfMass
automatically calculated by the Unity engine for a MeshCollider
or complex of primitives?
I don't want to arbitrarily set the centerOfMass
, since I want to use the auto-calculated one, but I want to apply rotational forces relative to the centerOfMass
.
I'm using addRelativeTorque
to apply rotational forces.
Thank you for your time, please ask me to clarify if necessary.
Comment
Best Answer
Answer by Max Kaufmann · Oct 28, 2010 at 05:25 AM
You could add an intermediate transform to act as an offsetter. E.g.
var offsetter = GameObject(transform.name + "Offsetter");
offsetter.transform.position = transform.TransformPoint(rigidbody.centerOfMass);
offsetter.transform.rotation = transform.rotation;
offsetter.transform.parent = transform.parent;
transform.parent = offsetter.transform;