Physics body getting stuck on another physics body

I have a game where the character is running along the ground which is made up of many rectangles. The character is a dynamic physics body, square shape, and the rectangles are a static physics body. In certain spots the character will get stuck while running to the right on top of the rectangles.
Both the character and the rectangles have 0 friction and bounce.

I have seen many threads on this issue but have been unable to find a working solution.
Any help would be much appreciated.

I can post code or screenshots if it is necessary. I have set the draw mode of the physics to hybrid and there is nothing blocking the way of the character so I’m at a loss.

Thanks,
David

Sorry for bumping this so soon but this issue is making my game almost impossible to play.

I would just add new features while waiting for a reply but i can hardly test them out as the game is useless with this problem.

David

If you mean that on a walkable floor made up of different physics bodies all lined up with each other, another body gets stuck when passing from one to the other (like it has hit their edge), it’s a known box2D issue.
You can either make sure that you only have a single, big physic body for each floor (iterating through all your tiles, you calculate the correct shape for it), or probably the fastest solution is to move up of 1-2 pixels the character on a collision with a new piece of the ground (just store that body in your character as a reference and at each new collision and compare the stored body to the new body the char is colliding with. If it’s the same, then don’t move the character, if not, move it and replace the reference of the body you had with the new one), or disable that collision altogether if it gets stuck.
Making the shape of the character different from a square also helps (circles should not have this problem, nor should squares with the lower part more rounded).
 

Thank you so much!

My long hours of searching have finally come to an end.

I ended up using a version of your last suggestion to get it to work.

What I did was change the shape from a square to a square with slanted bottom corners and it worked! So simple!

(new shape: {-w/2, -h/2, w/2, -h/2, w/2, h/2, w/2 -1, h/2 +1, -w/2 + 1, h/2 + 1, -w/2, h/2} )

Thanks again,

David

Great to hear! (;

Good luck with your project!

Sorry for bumping this so soon but this issue is making my game almost impossible to play.

I would just add new features while waiting for a reply but i can hardly test them out as the game is useless with this problem.

David

If you mean that on a walkable floor made up of different physics bodies all lined up with each other, another body gets stuck when passing from one to the other (like it has hit their edge), it’s a known box2D issue.
You can either make sure that you only have a single, big physic body for each floor (iterating through all your tiles, you calculate the correct shape for it), or probably the fastest solution is to move up of 1-2 pixels the character on a collision with a new piece of the ground (just store that body in your character as a reference and at each new collision and compare the stored body to the new body the char is colliding with. If it’s the same, then don’t move the character, if not, move it and replace the reference of the body you had with the new one), or disable that collision altogether if it gets stuck.
Making the shape of the character different from a square also helps (circles should not have this problem, nor should squares with the lower part more rounded).
 

Thank you so much!

My long hours of searching have finally come to an end.

I ended up using a version of your last suggestion to get it to work.

What I did was change the shape from a square to a square with slanted bottom corners and it worked! So simple!

(new shape: {-w/2, -h/2, w/2, -h/2, w/2, h/2, w/2 -1, h/2 +1, -w/2 + 1, h/2 + 1, -w/2, h/2} )

Thanks again,

David

Great to hear! (;

Good luck with your project!