There seems to be a lot of somewhat related questions answered already, but none I read answered my exact problem.
I have a 2D platformer whose world is made entirely out of tiles that are in a regular grid. When there is a collision, I just move the character to the position he was in prior to the collision and it works well enough for me.
The character can fly/slide in the world, so I also want to set the speed towards the collided tile to zero. Here lies my problem.
At the moment the only way to do this I can think of is to check the difference between the character position and the center of the tile. If (the absolute value of the) x-difference is greater, then it is a horizontal collision. If y-difference is greater, then it's a vertical one. However, as the character is sliding horizontally on tiles, from one tile to another, sometimes he stops at the seam of the tiles because momentarily the x-difference becomes a tiny bit greater than the y-difference (due to float inaccuracies I suspect). I don't know if it's possible to change this algorithm to fix this, or if I need a new one. Any algorithm will do, as long as it fulfills the "requirements" stated above.
If at all possible, I want to treat the x- and y-collisions identically, because the movement is not just walking horizontally.
Image illustration: http://i.stack.imgur.com/URkoV.png