Hey,
I’ve recently asked about player getting stuck between tiles, I solved that by adding a sphere collider to the player on the bottom. However, I encountered a new issue, which is having the player bounce when moving between two tiles (which they all have their own box collider), can anyone help me out figuring out how to solve this? or even how to approach moving in a tile-map in platformers.
Thanks,
The bouncing is being caused by several adjacent colliders being used for a single contiguous surface (i.e. one box collider per tile); it’s a known limitation of Box2D, the engine that Unity’s 2D physics is based on. The “Why does the character get stuck” section of this article might give a better understanding of what’s happening when a character walks across a floor made out of multiple colliders. While the article mainly talks about the player getting stuck, like the old problem you had, the problem can also manifest in the form you describe.
Imagine a ball rolling quickly across a surface that has a small step in it, say 1/8 the height of the ball. The ball would sort of “pop” upwards when it hit the step, as if it had gone off a tiny ramp. That’s basically what’s happening here, despite the two surfaces being even.
The fix in Unity is to use an edge collider that runs along the border between solid and non-solid tiles. The easiest way would be to hand-author these edge colliders, but if you’re making a whole tile-based engine sort of thing, it may be worth trying to create them programmatically, although how to do that is a whole question unto itself.