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

How to handle specific collisions?

Topics: Developer Forum, User Forum
Jun 5, 2013 at 6:12 AM
Im currently working on a game using farseer and gleed2D for xna 4.0. (which btw, is awesome!!!)

buutt, in my levels i need a exit point, which will be a static circle object and when my player collides with it i'd like to be able to excute some specific code. How would i go about doing this?
Jun 7, 2013 at 3:19 PM
To do this, start by creating a body Circle
Body endLevel = BodyFactory.CreateCircle(physicWorld, fMeterCircleRadius, fDensity, vWorldPosition);
endLevel .IsSensor=true; // To have the detection but not the physic reaction
endLevel .OnCollision += OnEndLevelEnter;
endLevel .OnSeparation += OnEndLevelExit;

Declare after the callback like this
public bool OnEndLevelEnter(Fixture fixtureA, Fixture fixtureB, Contact contact)
return true; // if you return false, the callback OnEndLevelExit will not be called

public void OnEndLevelExit(Fixture fixtureA, Fixture fixtureB)
Jun 8, 2013 at 1:10 PM
Thanks! That's exactly what I was looking for! I didn't think it would be so simple honestly.

Is there a thank button or something of the likes up here?