Need Advice on Using Tilemaps for a 2D Platformer with Arcade Elements in Unity

I'm developing a pixel art game in Unity that combines 2D platformer and arcade elements. In the game, players will race against each other while using funny mechanics and combat systems to knock their opponents back or push out of the map like in the stickfight the race. Currently, I'm using tilemaps for level design, but there can be additional mechanics, such as a hook mechanism, such mechanics that interact with the environment in different ways.

My concern is whether using tilemaps is the right approach. I'm encountering issues with sharp corners and friction causing the character to get stuck on the edges of tiles when jumping. These issues can be fixed with edge detection, but I'm worried about potential problems that might arise later and I can not foresee. Should I continue using tilemaps, or should I consider creating my own collision shapes?

9852900--1418601--Screenshot_2024-05-24_at_12.35.18.png

If you are using a tilemap collider, then each tile has its own collision box. Sometimes your character can trip up on the transition from one tile to the next. You can avoid this issue by using a composite collider. This will merge all of the tiles into a single collider with a continuous edge.

(Note that adding a Composite Collider will always add a Rigidbody2D to the object, so be sure to set that to Static)
9853812--1418856--upload_2024-5-24_11-20-53.png

If you are seeing a non-smooth collider even after using the composite collider, then you should check is the physics shape of the tiles. If you have set "Generate Physics Shape" box in the sprite asset, then Unity will try to draw a tight polygon around the non-transparent sprites in your tiles.
9853812--1418859--upload_2024-5-24_11-22-37.png

If Unity has already created a physics shape that is irregular, then you may need to use the Sprite Editor to define a custom shape for the tiles that is just a square.

1 Like

Thank you for much for the answer.

Since I already using a composite collider I dont have a tripping up problem from transition between tiles, right now, my only problem is when my character jumps and I move it in the air towards a wall or the edge of a platform, it gets stuck due to friction.

I solved the wall issue by changing the wall's physics material to have 0 friction. However, I can't set the friction to 0 for a platform because I need friction to on the platforms in terms of my movement mechanics.

Here is an ss of how it gets stuck in air while I am holding the key A down (to go left)

9855549--1419243--Screenshot 2024-05-26 at 10.50.52.png

You could set your character's friction to 0 while they are in the air and then restore their normal friction when they are on the ground.

1 Like