- Home /
[2D] Player keeps getting stuck/bounce on tiled ground
I've had this problem so many times and I cannot seem to fix it. My player keeps getting stuck on the floor that I made all the time, and sometimes even bouncing up. The tiles are perfectly placed next to each other and there are no visible gaps or height differences at all.
I'm confused why this is happening, some people say it has to do with precision issues within the Unity 2D engine, but it seems they're not going to fix it if that's the issues (more info here).
So, I'm assuming I'm doing something wrong but I can't find out what... :/
Here's what I've tried so far :
Instead of giving the player a Box Collider 2D, I gave it a Circle Collider 2D instead which cut down on the "stickiness", but it still get s stuck a lot.
Adding a almost zero friction Physics Material to the player as well as giving it to the ground tiles.
Using Edge Colliders on the ground instead of Box Colliders.
Lowering the "Min Penetration For Penalty" value in the Physics2D settings tab.
Make the "Velocity Iterations" and "Position Iterations" higher and lower in the Physics2D settings tab
None of these things has worked and I can't seem to find any other fixes for this issue.
Updates ;
I removed the edge colliders from the ground and replaced them with box colliders again, since that didn't solve my problem.
Adding the circle collider fixed the getting stuck, however now it bounces instead.
Added a video preview of my problem >here<
Answer by MelvMay · Sep 26, 2016 at 03:11 PM
There's no reason it'd get stuck unless you're forcing overlaps by moving the body directly or via changing the Transform.
If you're instead talking about expecting multiple separate colliders to act as one continuous collider surface then you'll not get that to work as each collider is solved separately no matter how perfectly you think they are aligned as explained in the link you referred to. You do say you're using Edge Collider which completely solves that as it's a single collider (assuming you're using a single collider with multiple edges and not multiple edge colliders each with a single edge).
Maybe a video will clearly demonstrate what you mean by 'stuck'.
Forgot to mention that the player no longer gets stuck but bounces ins$$anonymous$$d, most likely because I changed the Box Collider on the player to a Circle one (as mentioned in the post).
I also forgot to mention that i removed the edge colliders and replaced them with box oneas for the ground again.
Here's a video "preview" of the bouncy problem : (click me)
And I'm setting the velocity of a Rigidbody2D to make the player move.
A single edge collider with multiple edges won't exhibit this problem which is for ther reason you referred to in the link. It won't be fixed by Unity because it's related to a fundamental way that physics for collider is resolved as I already mentioned i.e. one-by-one. This is the same for Box2D as it is PhysX.
One thing that will help you in the future will be the CompositeCollider2D which can merge collider geometry together into a continuous surface. That is available in the 2D Experimental Preview #2.
Beyond that, there is nothing you can do beyond using an EdgeCollider2D to produce a continuous surface.
Alright, I guess I'll have to do that then :/ Thanks for your help :)