# How do I make a tile passable in one direction only?

I want that my character can jump through some of the tiles, like Mario does in this video: http://www.youtube.com/watch?v=zIPYzbNrNhc

In this video, Mario jumps up through orange platforms, but does not fall down through them.

How can I do that with Farseer?

• Related but for a different engine (some of the answers may still apply) gamedev.stackexchange.com/questions/50693/… May 13, 2013 at 21:26
• I removed your code and "What should I change in my code?", because I felt that made this question too localized. If you feel like that's the question you need answered, you can revert it. However, I would vote to close if you choose to do that. :) May 13, 2013 at 22:36

If you look at the Velcro Physics (formerly Farseer Physics) code, you'll find an example called OneSidedPlatformTest. Inside this test is the code required to create Fixtures that act in the manner you're requesting.

Essentially, you override the PreSolve function in the following way:

protected override void PreSolve(Contact contact, ref Manifold oldManifold)
{
base.PreSolve(contact, ref oldManifold);

Fixture fixtureA = contact.FixtureA;
Fixture fixtureB = contact.FixtureB;

if (fixtureA != _platform && fixtureA != _character)
{
return;
}

if (fixtureB != _platform && fixtureB != _character)
{
return;
}

Vector2 position = _character.Body.Position;

if (position.Y < _top + _radius - 3.0f * Settings.LinearSlop)
{
contact.Enabled = false;
}
}

This relies on testing the top of the platform against the position of the character. Assuming the position of the character is at its feet, no collision is returned when the feet are not near the platform.

This method may work for you, but once you've implemented this override, it should be trivial to change the detection method to other strategies. For example, you could test the direction the character is traveling and only apply collision if the character is above the platform and not moving up.

• +1 with the small addendum that, if implementing the last line in Byte56's answer, ensure that the character is completely above the platform/past object to avoid any oddities like a short jump getting the character stuck midway. May 14, 2013 at 5:25
• I always get this error message: 'WindowsGame2.Game1.PreSolve(FarseerPhysics.Dynamics.Contacts.Contact, ref FarseerPhysics.Collision.Manifold)': no suitable method found to override What is wrong? May 14, 2013 at 8:38
• Sorry Bryan, this is not a copy/paste answer you need to look at the example in code, see what overriding entails. This is a common programming practice. If you still can't figure it out, head to chat and I or someone else will help you. May 14, 2013 at 13:39