I'm not sure if the title is correct (please comment if it is not). I have a sprite (rectangle body), and I'm applying force on it to make it move from left to right and then go backward. The platform consists of a few rectangle blocks of same size, lined up, with no distance between them . What they form is a perfectly straight line. The platform can be flat or sloped.

What I want

The sprite moves smoothly forward and backward on the platform.

What actually happens

The sprite is sometimes clogged at the point it moves from one block to another, even there is no space between blocks at all. Also sometimes at that point a collision is registered.

I have tried to search and found something called "internal corners", but have no clue how to fix this problem. Is there a way to get around? Thanks!

  • \$\begingroup\$ One dirty solution might be to add a flat box on the platform and then move the sprite on it. \$\endgroup\$
    – noob
    May 31, 2012 at 15:30
  • \$\begingroup\$ Insufficient detail. Does your game have gravity? What does your current solution look like? \$\endgroup\$
    – Anko
    Jan 23, 2013 at 22:20

1 Answer 1


The problem is illustrated as such:

hidden edge collision

The moving object "sinks" into the ground slightly. This may be gravity, this may be slight errors in precision, it doesn't matter.

While moving right, the bottom of the player collides with the vertical edge of the right tile, catching so to speak on its corner.

The fix is to remove this internal edge. Since the moving object can't be between two tiles, that edge is irrelevant. The only edges that the moving object can collide with are external edges, such as the top edge in this example.

You generally need to post-process your tile map to identify these edges. You can easily examine each tile to see what neighbors it has, telling you if any edge is external (no adjacent tile on that side) or internal/hidden (adjacent tile on that side).

If you write your own simple physics, you can then only check agsinst edges that have the external flag set.

For Box2D, there is something called an Edge Shape and edge chains. You will need to find all external edges and connect them (start with any external edge and then find the next external edge sharing a vertex, until it loops) and build an edge chain accordingly. This is how Box2D deals with this case.

Note that when connecting edges, you may run into a case where a single vertex is shared by more than two edges, like so:

kitty corner

You want to ensure that the edges with the blue normals are connected, and edges with red normals are connected, but never with the edge with a different color. If you get a list of all edges sharing a vertex, pick the edge on the "other" tile (which you'd do anyway even when only two edges share a vertex, to avoid picking yourself). Then pick the edge who's normal is not your normal in the opposite direction (that can't happen in a sane world, it geometrically makes no sense). That edge is the one you want join with.


You must log in to answer this question.

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