Attaching multiple fixtures to a body?

Topics: User Forum
Jul 28, 2011 at 5:26 AM

Neither the Farseer documentation page nor the Box2D manual covers this topic. How can I attach multiple fixtures to the same body?

I have created an object and assigned its Body body = BodyFactory.CreateCircle(world,0.5f,2);

(That works fine, of course)

Then I try to attach another fixture to the body:

Shape sh = new CircleShape(0.5f,2);

body.CreateFixture(sh);

 

...but nothing has changed when I run the program. What am I doing wrong? Is there somewhere I could have looked to figure this out on my own?

Thanks.

-dsc

Jul 28, 2011 at 9:29 PM

That's really strange since that should work.  I use FixtureFactory.AttachCircle(radius, density, body) and looking through the code it does the exact same thing. If you have the debug panel visible check the fixture and body counts with and without the new fixture.

Jul 29, 2011 at 3:52 PM

Thank you for the quick response. I rechecked based on your advice and the FixtureFactory method is indeed identical.

I then made the radius of the new circle much larger, and found that these shapes ARE being attached....but how do I attach them at a point other than the center? I would like to be able to attach square shapes to each other.

Thanks,

-dsc