- Home /
controlling the center of mass for a car
how would i use the rigidbody.centerOfMass to lower a cars chance of rolling over
Answer by Owen-Reynolds · Jan 02, 2013 at 04:52 PM
rigidbody.centerOfMass=new Vector3(0,-1,0);
To get a feel for how to change it, helps to see what it is now. centerOfMass is an offset from the (0,0,0) point of your object. Say you have a car with (0,0,0) on the bottom, so the bounding box is all above and maybe a little more forward because of some cool fins. If you print centerOfMass, you might see something like (0, 2, 0.4);.
If you want to go off of what the computer has done; maybe move it down by 1 and 0.5 forward to account for the heavier engine; can say rigidbody.centerOfMass += new Vector3(0, -1, 0.5);
"whenever I try to put in a decimal I get an error"
Just add "f" after the decimal, like: new Vector3(0, -.5f, 0);
Or, add "(float)" before the decimal, like: new Vector3(0, (float)-.5, 0);
Answer by SuperSuperNono · Mar 23, 2016 at 01:03 PM
Hello every body,
I have a question concerning the location of the centre of mass. I am working with two "Rigidbody" which are joined together (with the property "Fixed joint"). I need to know the accurate location of the new center of mass. How is it possible?
Thank you very much!
Your answer
Follow this Question
Related Questions
Camera Following Rigidbody 0 Answers
Net Force apply in Unity? 1 Answer
What unit is Rigidbody Mass based on? 3 Answers
Composite Rigidbodies - Mass Distribution 0 Answers
What's the Rigidbody's gravity unit? 1 Answer