PhysicsSimulator instances

Topics: Developer Forum, User Forum
Dec 2, 2008 at 7:59 PM
Quick questions if someone knows the answers:
1.) I dont think the documentation explicitly says it, but I assume you only want one PhysicsSimulator instance for your game correct?

2.)Question one was came up because I am having problems with collisions. I created my PhysicsSimulator in my Game1.cs file. I then have a Character_body.cs class that takes a PhysicsSimulator argument in the constructor.

So, I create the Simulator in Game1, then pass the refernece to my Character object. In the character object i create my bodies and geoms, using "myPhysicsSimulator" to add them to the engine.

I am not getting any collision, but my bodies do get affected by gravity (they just fall through the ground). I get no compile or runtime errors. The simple geom's that i am using worked in a similar test with the engine. (but in that case, everything was in Game1.cs)

2.a)What is the best way to (if needed) pass references of the PhysicsSimulator to my classes?

*(this is similar to the post earlier about the guy who forgot to add his geoms to the simulator. mine are being added, i thought)


BTW- Have been playing with Farseer since Great work on the improvement to the documentation. And I LOVE the texture-vert idea. I am going to be experimenting with that as soon as I get my collisions to work again.
Dec 2, 2008 at 8:29 PM
1. Yep, one phsyics simulator. If you have a bunch of geometries colliding with each other and another bunch colliding with each other - BUT the bunches does not collide with each other - you might benefit from running 2 physics simulators in a multithreaded scenario. Just saying that the possibility exists.

2. You need to make sure that you are actually adding the geometry to the engine. If you indeed are adding it to the engine, make sure that you have set the correct CollisionGroup. Geometries in the same CollisionGroup does not collide with each other. (remove all references to collision categories such as CollideWith and CollisionCategory. They are only for advance scenarios)

2.a We have seen 2 ways:

1) Pass by reference on each use
2) Create a globally avaliable instance that. (See the Singleton Pattern on wikipedia)

The way you choose is up to you. It's really only what fits you the best.


Thanks for the feedback. We worked very hard on the documentation and tried to make everything just like 1.0.0.x but still keep it fresh by giving you guys some new features to play with.
Dec 2, 2008 at 8:47 PM
Ok. The problem was with the keyboard operator. No matter how many times i looked at my code, I did not see that the character body parts were indeed NOT being added to the simulator. (ground was, body parts not)

Talk about blind spot! (see my * askterisk note in original post) 

All is working, thanks for the help.