- Home /
Rigidbodies rotate around local pivot point rather than center of mass
TLDR: childless objects, each with a rigidbody and a collider, float around and collide. Upon collision they rotate around local pivot points rather than their centers of mass.
I'm trying to work on a simple physics playground where you can drag objects around and stack them onto each other. Gravity is turned off per object so that the object would float in the air while being dragged around, and is turned back on when the object is dropped. The objects have their pivot point at the bottom for ease of placement. The objects do not have any children, each has either a box or a convex mesh collider, each has a Rigidbody componenent. On colliding each other the objects start rotating while floating in the air, which is what I want, but for some reason they rotate around their local axis pivot point rather than their center of mass. I thought it should be the other way around, am I mistaken?
I've checked things with DrawGizmos and seems that centers of mass are calculated properly, right in the center, halfway above the pivot (which is touching the bottom). Sure, I can move pivot points to the centers for each object, but maybe I'm doing something wrong with my RigidBodies? Reading other people's question about center of mass rotations reveals that for the others the problem is reversed: objects rotate around center of mass for them while they want rotations to happen around pivot or some other custom point. My Unity version is 2018.3.11f1 if that helps.
Answer by Bunny83 · Apr 07, 2019 at 11:58 AM
Well, it's hard to tell what is wrong in your case, but yes, rigidbodies under physics control rotate around their center of mass. Though keep in mind that the center of mass is based on the colliders, not on the mesh. You haven't said what kind of collider you use. Keep in mind that dynamic rigidbodies with mesh colliders can only use convex mesh colliders and they can only have 255 vertices. Convex mesh colliders may have a different shape than the actual mesh. Do you set the center of mass yourself? Or do you let Unity calculate it?
I did not know center of mass is based on collider rather than the mesh itself, thank you! The colliders I'm using in the scene are either convex mesh (same mesh as the object) or boxes. I've checked things with DrawGizmos and seems that centers of mass are calculated properly, in the center of the corresponding meshes right where I'd expect them to be, halfway above the pivot (which is touching the bottom). $$anonymous$$ust be some bug then or some convoluted project setting maybe. I'll try to investigate, though I already resaved my models with their pivots close to their visual centers and decided to move on.
Answer by roger0 · May 21, 2021 at 05:50 PM
I just did a test and it does appear that adding force to a rigidbody will make it apply the force on its pivot point.
Your answer
Follow this Question
Related Questions
How can I rotate around with a Rigidbody while respecting physics? 0 Answers
centerOfMass and local coordinate origin 1 Answer
Rigidbody rotation around CenterOfMass 1 Answer
Rigidbody Inside Rigidbody 2 Answers
Rigidbody Rotation Problem 0 Answers