Collision with non Farseer physics objects

Topics: User Forum
Aug 27, 2009 at 6:11 AM
Edited Aug 27, 2009 at 6:14 AM

I've been racking my brain on this for awhile as well as searching for other people with the same idea and how they put it together.  Sorry I don't know the Physics engine as well as I'd like but I'm working on that.  Basically I started off by trying to create animated geoms to work with my spritesheets because I'm trying to do a sidescroller much like metroid or castlevania sotn, but found that was an enormous headache.  I was able to create all of the geoms but swapping them out per frame didn't seem to want to work that well for me.  I believe I've came to the realization that it would be better to have any "character" (pc or npc that is animated) not be a Farseer physics object and do my own physics type stuff, I think that's what Huehnerschaender meant in this post .  I am just not sure what info/data I would need to give the Physics engine let alone where to give it to fire a collision. Would I just have to make my own collision detection?

I would imagine this is possible.  This is a great engine and I would love to be able to use it I just can't really move forward (well kind of) till I have the collision figured out between characters and physics objects.  Hope I'm making sense heh.  If anyone has any ideas, sample code, concepts or anything else that would be fantastic.


for the devs:

Great work,  I tried to use the engine awhile ago but my xna knowledge wasn't up to par with what I wanted to do, but I come back to it and it just keeps getting better.  Thanks for the hard work and being smart lol,  I'd be lost with out all you smart people.


Thanks again,




Sep 1, 2009 at 4:41 PM

It may be expensive to swap out Geoms the way you were talking, depending on the way you do it. It should be reasonably efficient if you apply all geoms (as long as there aren't too many) to your character's body, and enable only the geometries that are desired for that frame.

If the issues you're having about swapping Geoms is that they make things get knocked around or something like that, it's probably because you're placing a geometry down such that it immediately overlaps something else, causing a violent collision. That's not a very nice thing to have happen, and you'll likely have to find some way to avoid it.

Alternatively, you can have a single bounding geometry that always surrounds your player, and then with its OnCollision method, figure out if it really should be colliding or not. I'm working on something where I handle collisions between a sprite (pixels) and a polygon. It's just an idea... I'm not sure if there's a better way, but tell me what you decide to do!

Sep 1, 2009 at 5:31 PM

I kind of figured out a way to do it but I haven't tested the expense yet.  I started to use the FlatRedBall engine and use Farseer with that so a bunch of other hurdles have popped up for me to jump over first.

Basically I just created a list of Geoms for my animation and had the index of each Geom coincide with my current frame,  however the way I did it was removing/adding it to the Physics simulation every frame which messed up the physics because all the physics from the last frame didn't carry over to the new frame.  So I could probably enable/disable which geom to use for collision (but keep updating the other geoms positions, etc) each frame and make sure they are all on the same collision group I don't know the performance issues that may arise from it.  I thought about doing it like you said and do a per pixel collision after the geom collision haven't been able to try it yet though might be a great way to go.

I'm a pretty terrible programmer so I may be thinking in the completely wrong direction :)

Thanks for the reply,


Sep 2, 2009 at 12:03 AM

You can set many geometries to the same body with the method:


Any geoms sharing the same body will never collide. For the one geom you wish to use in a particular frame, you can write:

myGeom.CollisionEnabled = true;

and make sure that it is set to false for all other geoms you have on standby. I suggest you try this before attempting pixel collision.