The script on my Rigidbody allows the user to change its position and rotate it (through AddForce and AddTorque, respectively). However, when I rotate it, it moves ever so slightly (+/- 1 distance), which has a notable effect on the game. How do I make sure that the Rigidbody rotates around its center without changing its position at all? I thought about freezing the position, but that would bring the object’s velocity to zero, correct?
Check the center of mass of your Rigidbody.
Debug.Log (myRigidbody.centerOfMass)
If it’s not (0, 0, 0) then the object’s position will change when you use AddTorque.
Colliders of its children have an effect on the center of mass.
Example:
Parent (has Rigidbody)
– Child (has collider). Local position is (0, 0, 5)
If you add torque to the parent in my example then the parent’s position will change.
You can change the center of mass if you want:
myRigidbody.centerOfMass = new Vector3 (0, 0, 0); // or just Vector3.zero