world.addBody() ?

Jan 21, 2012 at 1:31 PM

I'm currently starting a game with Farseer physics and I'm hoping someone can explain this to me. I see World has a addBreakableBody, addController ect. but is missing an "addBody" method. It has a "removeBody" method, but adding a body isn't as easy it seems. Could someone perhaps explain to me how I go about adding a body to the world?

 

 

Thanks!

Developer
Jan 21, 2012 at 5:17 PM

Use the body factory to create a body. You'll find plenty of examples in the samples.

Body body = BodyFactory.CreateCircle(...);

Jan 21, 2012 at 5:36 PM

This adds the body to the world? I tried it and then doing

Console.WriteLine(world.BodyList.Count);
and it printed 0 still

Developer
Jan 21, 2012 at 6:18 PM

Here's a link to the sample code, you'll see it create a simple Rectangle using the factory:

http://farseerphysics.codeplex.com/SourceControl/changeset/view/94324#1646066

Jan 22, 2012 at 3:22 PM
DavidLevesque wrote:

Here's a link to the sample code, you'll see it create a simple Rectangle using the factory:

http://farseerphysics.codeplex.com/SourceControl/changeset/view/94324#1646066

 

Alright, I think I get that bit now. But I'm stuck with collision not working. I'm not so great with this stuff, so I apologize for any easy mistakes I've made. I've put all of my source on Github.

 

https://github.com/RightLegRed/Reax/blob/master/Reax/Reax/LivingEntity.cs

 

That is the "entity" that will be the body and with the fixture, but it doesn't seem to want to print "hit", meaning the oncollide isn't being called. What have I done wrong?

Jan 24, 2012 at 5:42 PM

Bump, apologies if this is against the rules.