- Home /
Should Rigidbody.centerOfMass rotate my object? How to simulate a pendulum effect.
I have a simple cube with a rigidbody attached and I offset the centerOfMass to the right of my cube. Now, when I arbitrarily rotate the cube and start play mode, I expect the body not only to fall down, but also rotate in a way that the center of mass moves to the point closest to the ground, just like in real world physics.
So basically:
[ ] -- o
would rotate to
[ ]
|
o
Should this work as described or is it just not supported? What would be a clean way to add this pendulum like behaviour to my rigidbody without using joints? I also can't just rotate the object towards the ground every frame, because I also want to allow other physics force to tumble/rotate the object.
Answer by Bunny83 · Aug 13, 2016 at 11:51 PM
No, that's not possible. For that you would need "real" air resistance. Just an offset center of mass won't rotate the object at all. Rigidbody physics is a quite simple physics simulation. Real air resistance would require some sort of fluid dynamic simulation.
An object with an off center of mass will rotate it's center off mass downwards because the counter forces (which act equally across the whole surface) will push the part that's further away from the center of mass more so a torque is generated.
Air resistance doesn't exist in PhysX. Unity has an arbitrary linear "drag" but it purely acts on the center of mass. So "drag" only affects the linear velocity and angularDrag only affects the angularVelocity.
Thanks, makes sense! Slerping towards Vector3.down in FixedUpdate actually works good enough. I was worried that it would counter all other torque forces, but it doesn't.
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
Object move on z axis while giving force on x axis 0 Answers
Issue w/ Difference between Cube and Capsule 0 Answers
How to limit an object's position to a spherical radius? 0 Answers