Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I'd like to know how we can achieve the doodle jump type physics using andengine.

I mean the character is not colliding with the ground blocks when he moves upwards but will collide when he came downwards and will make a jump from their.

Can it be achieved using the collision filter? If yes how? Is it possible to enable and disable collision filter for particular bodies dynamically?

share|improve this question
Set collision filter to "can't collide" when hero.getY() + hero.getHeight() > platform.getY(), otherwise set filter to "can collide". You will have probably not more than 5 platform currently on the screen... and it will not be problem to manage this.. –  Racoon Feb 8 '13 at 10:06

2 Answers 2

I'm not familiar with AndEngine, but the obvious general approach is to turn off collisions between the character and platforms whenever the character's vertical velocity is positive (i.e. the character is moving upwards).

If your platforms (or character) have a non-negligible thickness, you may need to deal with the situation where the character partially overlaps a platform at the top of their jump. There are (at least) two ways to handle that situation: either ignore collisions with platforms which the character already overlaps (which causes them to just fall back down if they didn't jump high enough to fully clear the platform) or detect such overlaps and move the character up until they're standing on the platform, perhaps accompanied by a special grabbing and climbing animation.

Note that, if your platforms are not always perfectly horizontal, you'll need to take some extra care. First, when the character is running uphill along a platform, you obviously don't want them to sink into it; this may require separate treatment of running/standing characters as opposed to jumping ones. Also, simply checking the vertical component of the character's velocity is not always correct for highly tilted platforms; what you really need to test is the vector dot product between the character's velocity and the platform's (upward-pointing) surface normal. You may also want to set a slope cutoff above which platforms are simply treated as walls, and cannot be jumped through.

(As an alternative to a simple cutoff, you could do something like taking the platform's upward-pointing surface normal, rotating it around the vertical axis to face the character, and then taking the dot product of the character's velocity with the rotated normal. If I didn't mess up the math, that should restrict the range of directions from which the character can pass through the platform as it gets more and more vertical, like this:
Here, the thick black freehand line is the platform, and the cones show the directions from which the character can pass through three different points on the platform.)

share|improve this answer
You have my upvote, sir. In particular, for the classiness of this approach: "detect such overlaps and move the character up until they're standing on the platform, perhaps accompanied by a special grabbing and climbing animation." –  Cameron Fredman Feb 11 '13 at 21:36

Ilmari Karonen's answer would suffice if you're coding the collision and physics yourself. Otherwise I assume you wanted to use AndEngine's Box2D wrapper for physics since you mentioned "collision filter".

In that case, you probably want to refer to this tutorial on one side platforms. General idea is to use BeginContact and EndContact callbacks to disable/enable contact based on whether object is moving up or down. It's not exactly as simple as it sounds due to some quirks in Box2D.

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.