Page 1 of 1

Center of mass

Posted: Fri Jun 16, 2017 11:21 am
by varpeti
Hello!
I have a little problem:
When i was trying to attach a Shape to a PolygonShape Body, the Body's mass center, wasn't changed.

I tried using

Code: Select all

body:resetMassData()
but it isn't work.

Image
On the right: Circle shape was created with body before polygon was attached.
On the left: Polygon shape was created with body before circle was attached.
Filled circles: shapes mass center. (calculated)
Small circles: bodies mass center. (getWorldCenter)
Big circles: bodies position. (getPosition)

Thanks for your help!

Re: Center of mass

Posted: Fri Jun 16, 2017 12:15 pm
by raidho36
Seems like a bug. You can however set mass data manually.

Re: Center of mass

Posted: Fri Jun 16, 2017 12:28 pm
by varpeti
Yeah, i'll do that.

P.s.:
I create a polygon shape with "kinematic"a circle shape with "dynamic" type. Thats why the difference. -_- (wanted a rubber duck)

Re: Center of mass

Posted: Fri Jun 16, 2017 3:35 pm
by raidho36
Well that actually may be your issue - kinematic objects are meant to be moved around manually and are not supposed to react to other objects. Try using dynamic bodies for both of them.