Rigidbody2D.centerOfMass works incorrectly after transform scaled?

From the document:
The center of mass of the rigidBody in local space.

While the transform of the rigidbody2d localScale is one, everything works fine. But If the transform scale to big, or any of its parent scale to big, the centerOfMass will not accord with it, for example : the world pos of the center will not be scaled.

Is it a bug?

Scaling doesn’t directly affect the center-of-mass. What does happen is that scaling causes all 2D colliders to be recreated causing existing contacts to be destroyed (recreated during the next simulation step). When they are recreated and added back to the Rigidbody2D, the body calculates the center-of-mass. Scaling isn’t specific here though, the same goes for any Transformation that moves the Collider2D away from the Rigidbody2D it is attached to. The Collider2D offset for instance.

So while being something you shouldn’t do, yes, the center-of-mass should be moved unless it’s an explicit center of mass you have set.

Thanks for the details, it helps.
So i guess my best way is : Manually re-count the center of mass after scale take the scale into account.
I will try it.

BTW, MelvMay, i really need your suggestion of this topic :

Hope you can take a look at it.

In short: center of mass should be correct after any transform operation. Can you provide a simple bug report?

Yes, please check : https://fogbugz.unity3d.com/default.asp?917180_kpct684osf5u90pm

I just looked at it. You set the local center of mass explicitly so it’s not derived from the colliders and is therefore not affected by the Transform.

You set it to be (0.4,0.4) which is what it says in the Rigidbody2D info for local center of mass. The world center of mass is (0.49, -2.38). This world space has nothing whatsoever to do with the transform. It’s relative to the body position. You have the body position as (0.09, -2.78) so the world position is (0.4 + 0.09 = 0.49, 0.4 + -2.78 = -2.38).

This is what I said here. In other words, you set the value explicitly then you’re in control of it.

Sorry for my poor English understanding, i understand now. Thank you very much MelvMay.
(before that i guess the local thing will be of course synchronized by parent’s transform because it is “local position”)

Yes. LocalPosition here is local body space not local Transform space.