Player gets randomly stuck on tiles

I’ve had this issue for a while now in the Tilevania course, where my player character will randomly get stuck on a tile and will have to jump out to release himself. It will be fine for a while then randomly happen and once it does it will almost be constant. I thought it had left on its own but now I’m at the stage of making the 3 Levels it has showed its ugly head again.

Could I be doing something wrong with the player feet collider?

Hi,

Welcome to our community! :slight_smile:

Sometimes, the shape of the tilemap collider is not calculated correctly. If you spot a strange gap, disable the tilemap collider component and reenable them again to make Unity recalculate the shape.

Also try to set the “Collision Detection” of the player’s Rigidbody2D component to “Continuous” if you haven’t already.

Did this help you fix the problem?


See also:

2 Likes

Hi ! :slightly_smiling_face:
thanks but I tried those solutions and it still doesn’t work. :frowning_face: I only have this issues on the tile collisions themselves, if I put another game object as a child under my PlatformTileMaps and give it its own box collider I can walk along it fine with no issues
but this kind of makes the whole tilemap process redundant :worried:

Could you please share a bit more information on what you did in Unity? Screenshots would be helpful.

apologies I don’t know how to upload a video, these are 3 screengrabs which hopefully you can see my collider settings in



Thank you. Your screenshots were helpful. :slight_smile:

I think that the problem might indeed be caused by the tilemap collider. See here:

image

At the moment, each tile is surrounded by an edge leaving a tiiiny gap between them where the player could get stuck. To prevent that from happening, we need one edge around the overall shape of your tilemap.

Like this (but in green, not red):

image

Is there also a CompositeCollider2D attached to the “PlatformTilemap” game object? If not, add one and set the “Geometry Type” to “Outline”. In the TilemapCollider2D component, enable “Used by Composite”.

Hi once I changed the TileMapCollider2D to enable “Used by Composite” it just made my character fall through the floor and die. Not having much luck :sweat_smile:

And you also added the CompositeCollider2D? What collider shape did you get after you enabled “Used by Composite”?

If the player falls through the ground, it might be that the tilemap collider became a trigger collider. Make sure “Is Trigger” is not enabled in the CompositeCollider2D component.

thank you! that seemed to have solved the issue! :smiley:

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms