Collision weirdness at perfectly alligned TileMap edges with video; Workaround?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By collisionshaped

Hey guys,

I’m still a beginner at Godot and we are in the progress of creating a 2D game rn.

The problem is fairly simple I guess.

We have a TileMap (Autotiles) with rectangle collision shapes.
We have a map with those tiles being walls.
We have a player who can shoot RigidBody2D projectiles.
The projectiles should ricochet on the said walls.

The ricochet works perfectly on the walls, but not on the wall tiles edges (where the tiles are next to eachother). There is no actual separation between the tiles. They are aligned perfectly in the TileSet editor and on the map itself and there is no gap configured.

On the edges the projectiles (I tried different CollisionShapes: Capsule, Circle, Rectangle) will behave weirdly. If you aim directly at an edge the projectile will come right back at you or will even be reflected deeper into the wall, which will result in the projectile even go through the wall completely. For the player this behaviour does not make sense at all.

Have a look (CollisionShapes are visible):

I believe I understand why this is basically happening. The thing is, that at the edges there is no collision normal the projectile can reflect on normally, just two edges at virtually the same place.

My question is: How to deal with this kind of problem? Is TileMaps for something like that a bad decision alltogether?

Would it make sense to write custom reflection code and how to start?

Can the TileMap collision shapes somehow be fused together?

Thank you for any suggestion and help!

I tried to upscale the whole thing, so that I use FULL HD resolution just with upscaled pixelated textures, hoping that its just because of the subpixel scale, but it doesn’t help.

Bullets still can go through the walls at the tile edges. Its also possible to still shoot the edges, so that the bullet reflection is just wrong. :frowning:

TileMaps with Physics is probably not a good idea at all?

collisionshaped | 2022-04-19 13:37

1 Like