Game Development Stack Exchange is a question and answer site for professional and independent game developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have there serveral platforms. I would like to allow the player to collide only one time with the object! Hope you can help me

share|improve this question
up vote 2 down vote accepted

Farseer Bodies have a method like so:


What you are asking for is so that a body will only collide with another body once, so once those two bodies are separated from each other, they will no longer collide. Luckily, Farseer bodies come with an OnSeparation event.

body.OnSeparation += OnSeparation;

private void OnSeparation(Fixture fixtureA, Fixture fixtureB)

This will allow those two bodies to collide once, but after they separate they will no longer collide.

Depending on how your game works though, the OnSeparation event might be too sensitive, so you could handle it differently by keeping track of bodies that are colliding in the OnCollision event and then triggering something after a certain period of time, for example. The principle will remain the same however, still using the IgnoreCollisionWith(body) method.

You might also want to look into Collision Categories. You can define a Body's collision category and also which categories it collides with. This way, a body can avoid collisions with a whole group of other bodies, without having to use IgnoreCollisionWith against every single one of those bodies.

share|improve this answer

Well you can always attach an event to the bodies and when they collide with something check their ID's and only allow the collision if that was the first time (could do that with a bool)

   bool thingy=true;
      Body1.OnCollision += new OnCollisionEventHandler(Body_OnCollision);
      bool Body_OnCollision(Fixture fixtureA, Fixture fixtureB, Contact contact)
            if (fixtureA.FixtureId == 1 && fixtureB.FixtureId == 2 && thingy == false)
                thingy = true;
                return true;

                return false;
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.