This project has moved and is read-only. For the latest updates, please go here.

Farseer physics collision--can't figure out why it's not firing

Topics: User Forum
Apr 10, 2012 at 3:16 AM
Edited Apr 10, 2012 at 3:17 AM
Hello all!
I'm trying to integrate the Farseer physics engine into my XNA game and have hit a wall. I'm not interested in getting all of the physics to work, all I want is for it to tell me when 2 objects collide. I'm only using it for collision detection right now. However, I can't seem to get that to work.
In this super bare-bones app, I'm loading two textures, asking Farseer to create a polygon mesh of the texture, and adding the meshes to the Farseer World. I attach an event listener to OnCollison and expect it to fire whenever the two objects touch, but it never fires.
My sample code package can be downloaded at  Additionally, since the source is only 2 files, Game1.cs can be viewed here: and SceneItem.cs here: 
I'm using unmodified Farseer code downloaded from CodePlex here: (version 3.3.1). In the above code package, I have the project compiled to a DLL for convenience, but linking to the raw Farseer project will work just the same.
Can anyone take a look at the code and tell me why I'm not getting collision events to fire? Your help would be much appreciated. Thanks!
Apr 10, 2012 at 11:38 AM
Edited Apr 10, 2012 at 11:51 AM

For starters try making your bodies dynamic and not static on line 74. in SceneItem.cs as static bodies don't collide with each other per definition ;)

Next you should start moving your bodies via forces or applying an impulse. Just updating their positions won't work very well. For Farseer those bodies are just warping around and im not sure you'll get proper collisions for all cases. You could try to use sensors if you really just want to know if two fixtures overlap. But afaik even sensors only work against dynamic bodies and not against each other.

You may also need to scale your shapes down a bit and make sure your physics world is properly aligned to your drawing code. Search for scaling Farseer to MKS here on the discussion board.

Apr 10, 2012 at 5:05 PM

Thanks for the tip about IsStatic. I thought it just meant that Farseer shouldn't try to move it around itself.

I was able to get it to work by using your tip and from here:

  • Setting the bodies to Dynamic
  • Setting IsStatic to false
  • Setting IsSensor to true
  • After moving the object in Update(), but before the call to Farseer, setting each ItemN.FarseerEntity.Awake = true.

I will search the forum for the scaling stuff you mentioned. I read a bit about that before, as large worlds can cause the simulation to get out of control so scaling them down is necessary. Thanks for your assistance!