Collision issues in Unity


I’m having a weird collision issue where the player occasionally gets stuck on the wall.

We imported our map and collision data into Unity using SuperTiled2Unity, which then generated polygon colliders. We used two different layers (thus, 2 polygon colliders were created), as I have them set in different layers in Unity, as the layers affect the player differently.

While the wall usually works fine - when I’m bug testing and jumping against the wall repeatedly, occasionally, the player will get stuck against the wall, as the player’s rigidbody seems to think it’s touching a sub-pixel, or something to that extent, below it. I can still move the player left or right to fall off of the sub-pixel wall piece, but it’s definitely a frustrating bug.

I zoomed in on Unity super far, and I found the polygon colliders that were created aren’t exact around their individual tile pieces, and I’m guessing that’s the issue? (I tried uploading screenshots below to show this). It’s definitely in the sub-pixel range that it’s off, but it’s the only thing I can imagine is creating this bug.

Any thoughts on how to fix this?

For further clarification, I’ve also uploaded a zoomed in image of our character stuck on the wall. The red box is his box collider that should be detecting/hitting against the wall.

The green box is the collider he’s somehow gotten stuck on, which is the collider of the slightly-off-by-a-subpixel tile piece.


Screenshot 2024-06-06 at 6.37.41 PM

As a note:

I’m realizing (looking at this) no compositecollider was ever added. Is this why, and is there a specific layer I should be adding the composite collider to?