Apr 13, 2010 at 5:02 PM
Edited Apr 13, 2010 at 5:03 PM
Here is the one thing I noticed. The line:
geom.OnCollision += OnCollision;
I believe this is wrong, or at least, I've never seen it done like this. This is an example from a project of mine:
this.m_geom.OnCollision += new FarseerGames.FarseerPhysics.Collisions.CollisionEventHandler(Projectile_Collision);
I'm pretty sure you need some kind of EventHandler. Also, couldn't you change this?
geom.CollidesWith = ~CollisionCategory.All & CollisionCategory.Cat1;
geom.CollidesWith = CollisionCategory.Cat1;
Though I'm sure that is not a problem. It just seems redundant.
Ok, and the bigger problem I just noticed, I remember that
finding if a geom is NOT colliding with anything isn't as easy as it seems. You would have to also wire to the OnSeparation event, and keep track of what has been colliding and separating.
You also should set CollisionResponseEnabled to false, so the geometries will pass through each other (They will still fire collision events). I don't know for sure, but it seems like it could potentially cause problems.
Also, logically, your OnCollision event doesn't make sense. You set the CollidesWith to only Cat1, but then you check to see if the geometry collides with Cat2. The only category that will ever come into geometry2 will be Cat1, I believe.
I would think there has to be an easier way to do what you're trying to do...