Overriding collision detection

Oct 27, 2010 at 5:09 AM

Hi there,

I've been experimenting with FarSeer 3.0 for a few days now, integrating it in my current, still developing engine system. I've done the 'box-on-wheel' revolute joint combo to make a platformer style fixture setup, I've also done regular boxes and circles bouncing around. I'm using XNA 4.0, and I'm not quite handy at matrices and projections to really know what I'm doing to integrate DebugView, but I'm managing with just my textures. Cool stuff so far.

Which does bring me to a question I had while I was considering how to do certain things. Essentially, what I would like is to know if there would be a way to be notified when there is a collision, and to allow me to then act upon it.

Just to give an example, I have a character who lobs a fireball/dynamite/magic-missile underhand, and it arches up smoothly using Farseer gravity. It probably is a circle fixture with whatever texture I have, maybe a particle system behind it to make it pretty.

When it hits an enemy, the ground or a wall, then I'd like my entity to be notified with a message or event, telling me what it was that I hit (I imagine I'd have to pass the entity instance inside of Userdata to know that?), and in some cases, how I hit it (for instance, a fireball hitting a wall would cause an explosion spreading out away from the wall rather than willy-nilly through it). Then I can act upon it by removing the body from the world, replacing it with an explosion, do damage, etc. With my current knowledge, it seems that I need to do a collision checking in my own updating, which seems counter-intuitive given I have a perfectly functional physics engine integrated with its own broadphase and collision checking.

I did see the OnCollision delegate member, but I'm not exactly sure how to make it work or what it really requires. From the comment and parameters, it seems that it would be a subscription between 2 fixtures only, which wouldn't really work very well.

Any help would certainly be appreciated,



Oct 27, 2010 at 10:17 AM

I will put a description into the documentation.

Oct 27, 2010 at 10:43 AM

Look under the headline "Reacting to a collision".

Oct 27, 2010 at 1:24 PM

That's exactly what I was looking for. Thanks a lot for the fast response.