1
\$\begingroup\$

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 :

Bug

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 ?

\$\endgroup\$
1
  • \$\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
    Commented Jul 18, 2015 at 16:57

1 Answer 1

2
\$\begingroup\$

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.

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .