Search code examples
collision-detectionfarseer

Farseer: Collision detection, but without further body interaction


I have a ball that rolls through a maze-like world. I want an event to rise if the ball crosses a certain line. I don't want to place a texture at this line and I don't want the ball to be deflected. How can it be done?

Thank you!


Solution

  • In Farseer 3.3.1 you can create a body, say sensorLine with a fixture that has Fixture.IsSensor set to true. That way the fixture won't take part in collisions. You can then poll the fixture for overlapping bodies by iterating over sensorLine.ContactList or you can register a callback to the World.ContactManager.BeginContact event of your world instance.

    It sounds like EdgeShape would be the kind of shape to use for the fixture in sensorLine. If you only create a Farseer body, nothing will be visible on screen, so you need not worry about placing textures anywhere.