- Home /
How to stop Rigidbody2D from getting stuck on corners?
I have a tiny 2D game (scaled to 16 pixels-per-unit) with a character that must be able to walk up slopes. I gave it a CapsuleCollider2D and it seems to work fine. Additionally, my level is made up of several blocks that group into a parent with a CompositeCollider2D, as shown in pic below:
However, when jumping from one platform to the other, falling on the corner gets the character stuck as shown in this capture. I can walk off the platform to the right, but I can't walk onto it to the left or even jump (which I assume just means my ground checking method is always returning false while stuck).
I've searched online for the solution but most people seem to fix it by changing their previously BoxCollider2D into a CapsuleCollider2D but I'm already using that. Is this a consequence of the scale of the game being too small, of using GameObjects as platforms instead of Tilemaps, of me having the wrong Rigidbody2D settings, or perhaps something else entirely?
Answer by Sspyrshlsx · Aug 03, 2020 at 07:51 PM
This is a common problem with tile based games. You will notice this way clearly if you use a full tile based collider system (like 1 box collider for each tile). This has a pretty simple fix however.
1) Change the player's collider to 4 edge colliders to form a box collider. This should fix it.
2) Change the tiles' colliders to 4 edge colliders to form box colliders. This should also fix your issue.
Both solutions work, however you might want to use different solutions for different games. Do keep in mind though, that different edge colliders do not collide with each other.
Regards.
Edit: I was just trying to polish my character movement. I tried adding a box collider with some edge radius, this fixed the issue plus gave a better result - the edge radius made corner movement smoother.
Screen shots:
my drawing skills are perfect, don't you think so
Hey just want to say thank you for this information. For some reason I was looking for a solution to this a few months ago and found info on composite colliders and have been using that but it's not a perfect fix. This is so simple and works well.
Your answer
![](https://koobas.hobune.stream/wayback/20220612233205im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Is it possible to have continuous collision detection with dynamic points on Edge Colliders? 0 Answers
dragging on a gameObject messes with collisions 1 Answer
multiple objects on oncollissionstay2d 1 Answer
Player not taking damage on collision with enemy 1 Answer
Enemy bullets pass through my walls 2 Answers