Hi JGO-Community
I am currently working on a 2D platformer in Libgdx, using Box2D Physics Engine.
Ofc i have read some tutorials before i started coding, the most important are the one in the Libgdx Wiki and the one on IForce2D.
Therefore i knew about the “getting stuck problem”, when creating a tile-based game but i was almost sure, that clipping the polygon corners of my moving character would be enough in my case.
But it seems like i was wrong, the player charcter (currently the only dynamic body i am using, in future, the same problem will affect some types of enemies) sometimes gets stuck between tiles (not that often anymore but still to often) and, even more annoying, its speed is decreased a lot, when touching the floor after a jump.
So i guess i have to use another approach, but i just don’t know which one.
The IForce2D tutorial lists 2 other solutions:
- Edge Shapes: Instead of using polygons, i should use edge shapes, since there it does not happen that often. But as i have a tile-based game, edge shapes don’t seem to fit verry well, since tiles are polygons. OFC it would be possible, to have 4 edge shapes per tile, but if there is another posibility i would really like to stay with polygons
- Ghost vertices: This solution uses edge shapes again and adds Ghost vertices to it, which do solve the problem by affecting the collision response. But as it uses edge shapes, it does not really fit the planed design.
- Using a circle instead of a polygon. This is not possible, since the character is 1.8m tall and “only” 0.8m wide. So a circle is not possible, but maybe an elipse would solve the problem…
Another solution i can think about is, to “merge” adjacent tiles, but that would take some expense and i would need to rework the design a bit, so i would like to go with another solution, if possible.
So if someone else faced some simmilar issue and found an easy solution, without having to switch to edge shapes or merging tiles, please let me know.
Thanks a lot!