Here's my situation:

I have several objects that contain a body and a fixture. They are set to sensor = true;

atmosphere = BodyFactory.CreateCircle(world, atmosphereRadius / Level.METER_IN_PIXELS, 1f, new Vector2(pos.X, pos.Y));
atmosphere.IsSensor = true;

//JointFactory.CreateWeldJoint(world, this.getBody(), atmosphere, getBody().LocalCenter, atmosphere.LocalCenter);

this.registerBeginContact(new BeginContactDelegate(this.OnBeginContact));
this.registerEndContact(new EndContactDelegate(this.OnEndContact));

I commented out the join part because it didn't seem to make a difference either way. When the object we control goes enters any of these bodies, the even its fired properly. However, when the player object leaves the sensor field, it doesn't fire the OnEndContact method, EXCEPT if it was the last object that I call

this.registerEndContact(new EndContactDelegate(this.OnEndContact));

When my OnEndContact method is called by the EndContact event in ContactManager, it is called for ALL the delegates I registered, including the ones that are tied to the objects that are not getting these events to fire. The OnBeginContact delegates work perfectly, firing for every object, but the EndContact event does not.

Does anyone have any idea why this is happening or is this a bug in Farseer?

for reference my register methods look like this

public void registerBeginContact(BeginContactDelegate action)
    getLevel().getWorld().ContactManager.BeginContact += action;

public void registerEndContact(EndContactDelegate action)
    getLevel().getWorld().ContactManager.EndContact += action;

Thanks in advance.

this is also posted on the farseer code plex page Faeseer EndContact Discussion

  • \$\begingroup\$ I assume you've search all of your own code for a call of the form ContactManager.EndContact = action. \$\endgroup\$ Commented Apr 26, 2012 at 15:29
  • \$\begingroup\$ I can double check but the only place the delegates are being accessed is in the constructor of that class which all of these collidable objects are extending. So its that code I quoted here and that's it. Unless someone understands farseer better I'll just have to brute force this feature. I was hoping there was another way to register EndContact events \$\endgroup\$
    – Flostation
    Commented Apr 26, 2012 at 22:55


You must log in to answer this question.