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 a 32x32 sprite and I make some to be platform like this

for (int i = 0; i < 15; i++) {
    attachChild(new Ground(32 * i, 200, regPlatform, vertexBufferObjectManager, physicsWorld));

And I have another sprite (32x32 also) moving over those platforms (A player object)

attachChild(new Player(10, 10, regPlayer, vertexBufferObjectManager, physicsWorld));

And the physicsWorld connect the player like this (Where move=1 when user click right button, and move=2 when user click left button)

physicsWorld.registerPhysicsConnector(new PhysicsConnector(this, body, true, false) {
    if (move == 1) {
        body.setLinearVelocity(new Vector2(8, body.getLinearVelocity().y));
    } else if (move == 2) {
        body.setLinearVelocity(new Vector2(-8, body.getLinearVelocity().y));

The Player move smoothly form left to right and reverse. But sometimes, it is blocked. If the player move back a bit, and back again where it is blocked, it isn't blocked any more at the same place.

Anyone has any idea to fix this? May be it is bug of andengine and box2d and need some trick here? Please help me. (The two sprite above is just normal png with 32x32px)

Player image:

Plaftform image:

share|improve this question
Is it jamming itself into the other body? – Vaughan Hilts Apr 9 '13 at 17:24
I find a thread about box2d problem but not sure about it – MashiMaro Apr 9 '13 at 18:48
up vote 4 down vote accepted

AndEngine's physics extension is a port of Box2D. And Box2D's faq says this about tile based environments that should be "smooth":

Using many boxes for your terrain may not work well because box-like characters can get snagged on internal corners. A future update to Box2D should allow for smooth motion over edge chains. In general you should avoid using a rectangular character because collision tolerances will still lead to undesirable snagging.

For more information see this post:

Your description sounds like this problem.

share|improve this answer
Thanks Seth Battin for the answer. It is exactly my problem. I've read the post and have the solution:<br/>1. if you're using simple square/rectangular tiles everywhere, is to just merge any horizontally adjacent tiles into longer rectangles. This takes very little effort code-wise and should solve the problem.<br/>2. Most professional games using modern physics engines use smooth shapes, like capsules, for characters. Using box shapes for characters really only works well in systems that use pixel based collision with integral math (i.e. older console games). – MashiMaro Apr 10 '13 at 6:41

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.