Rigidbody changes position when I add torque. How do I stop this?
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, its position changes 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?
Upon closer inspection it seems that when I add torque in the x direction is when it moves. Adding a torque in the z direction does not. When the x torque is added, it seems as though the rigidbody rotates around a point outside of itself. I thought that adding torque made it rotate around the object's position. Am I missing something?
Answer by cstooch · Jul 11, 2017 at 05:26 PM
This might help answer your question:
http://answers.unity3d.com/questions/1035458/why-does-getcomponent-addtorque-ignore-the-pivot-p.html https://docs.unity3d.com/ScriptReference/Rigidbody-centerOfMass.html
You might need to specify the center of mass.
Thanks! Turns out I had been messing around with the center of mass before (I had set it to 1 unit behind the rigidbody) and totally forgot to set it back after I was done. One of those facepalm moments haha
Also, remember that colliders attached to the children of the Rigid object have an effect on the center of mass.
Your answer
![](https://koobas.hobune.stream/wayback/20220612130021im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Why does my rigidbody move it's transform while rotating? 1 Answer
How to Rotate Rigidbody to 0 Along the X Axis? 1 Answer
Turning faster right than left when using Rotate? 1 Answer
Cannot get rigidbody constraint to unfreeze 1 Answer
Disable gravity (freeze character in mid air) without him flying into space? 1 Answer