I'm using C++, Box2D and SFML.

I convert a Tiled map to world in my platformer game and I get stuck when I go against a block when I go forward like that :


I can use a circle as foot of my character but sometime, it make me jump a bit. Is there a solution or I must only do shape ?

  • \$\begingroup\$ I'm not sure if there's a better solution than changing the geometry, but a benefit of changing the geometry into a single rectangle instead of multiple squares would be that it would be fewer physics shapes to test against so should be more efficient and run faster. \$\endgroup\$ – Alan Wolfe Jul 18 '15 at 16:57

This is a quite known issue in box2d, the problem is that you are rendering a rectangle per Tile and in the joint of those there is a ghost vertex, you can read extensive explanation here: http://www.iforce2d.net/b2dtut/ghost-vertices

As for a solution to that i solved it by creating an object layer in my tiled map and created a Polyline object that defines how the body will look like.

Tiled Screenshot: tiled ground polyline

Afterwards obtain that layer and for each Polyline defined create a box2d Body using the vertices in the Polyline.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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