This project has moved. For the latest updates, please go here.

Center of mass issue with multiple fixtures

Topics: User Forum
Feb 10, 2011 at 1:02 AM
Edited Feb 10, 2011 at 1:16 AM

When first creating my game, which consists of a small helicopter, I only used a rectangle to represent the body as a whole. Now after looking at the multiple fixture sample I'm attempting to make it work with a simple skeleton of fixtures.

I've successfully created the body and added fixtures where i wanted to as can be seen here

My problem comes when I attempt to apply a force to simulate thrust and apply torque. What I want to do is apply the thrust at the center of the main body circle, but what seems to happen is the weight of the other fixtures causes this to occur off balance.

I created all the body fixture at point 0,0 with all other fixtures relative so I assume the force is being applied at that center point. Is it the other fixtures that are causing this balance issue? Is it possible to give them no mass and only have the center piece count towards the center of mass?

this is the code I've used to create the fixtures

            FixtureFactory.CreateCircle(22 / MeterInPx, 1, cBody, new Vector2(0,0));

            //Landing Gear
            FixtureFactory.CreateRectangle(40 / MeterInPx, 10 / MeterInPx, 1, new Vector2(0, 25 / MeterInPx), cBody);

            FixtureFactory.CreateRectangle(90 / MeterInPx, 10 / MeterInPx, 1, new Vector2(-2/MeterInPx, -25 / MeterInPx), cBody);

            FixtureFactory.CreateRectangle(40 / MeterInPx, 10 / MeterInPx, 1, new Vector2(-35 / MeterInPx, 10/MeterInPx), cBody);

            FixtureFactory.CreateCircle(14/MeterInPx, 1, cBody, new Vector2(-60/MeterInPx,7/MeterInPx));

Help would be greatly appreciated!
Feb 10, 2011 at 1:19 AM

You have one body with multiple fixtures. All the fixtures are taken into account when calculating the centroid.

You can try to change the centroid manually by setting Body.LocalCenter.