I am relatively new to game development, and am working on a simple 2D platformer. I have created a tilemap and painted some tiles for the character to walk on.. but he is getting stuck. Yes, I know this is a common question and I did find some answers (including this one: Player gets stuck on edges between TilemapCollider2D tiles), but none seem relevant for me. The thing is my tiles are not flat.. they have pointy edges due to grass.. see the image below:

Grass tile with jagged collision edge

As you can see, the edge is not flat. I have overcome the problem of getting stuck by changing the "Edge Radius" to what you see in the above screenshot and that works, but the character now looks like he is floating slightly above the ground. Is there any way I can just tell Unity to ignore the jagged grass and make the collider flat and move the edge of it down a bit? That way it would fix the issue and also have the added bonus of looking like some of the grass is behind him and some in front..


Thanks to @DMGregory, the solution for anyone else with the same question is as follows:

  • Find the sprite in your project
  • Open the sprite editor from the inspector
  • Edit the collider

If you don't set any collider here, it appears Unity will figure it out for you instead.. which in my case was not appropriate. I just made my collider into a box.. as follows:

enter image description here

and so my Scene view now appears as follows:

enter image description here

Additionally, I removed the Rigidbody 2D and the Composite Collider 2D and unchecked the Used by Composite checkbox in the Tilemap Collider 2D.

It now works great.

| improve this answer | |
  • 1
    \$\begingroup\$ You will probably still want the composite collider here, as it can also help with efficiency by combining large groups of colliders, and avoid snags at the seams between tiles. \$\endgroup\$ – DMGregory May 15 at 13:25
  • \$\begingroup\$ Thanks for that info. I've added the composite collider back and I see what you mean. \$\endgroup\$ – Matt May 15 at 13:41
  • \$\begingroup\$ Great work solving the problem! I'm looking forward to seeing your game develop. :) \$\endgroup\$ – DMGregory May 15 at 14:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.