unity-game-enginecollision-detectiongame-physics

Unity Collision between Box Collider 2D and Tilemap Collider 2D not working


For practice I want to have an island surrounded by water.
Where I can move freely on the island and use water as a "wall" to block movement in water.
Thats the grid map I build:

Land(green) and water(blue) are on separate layers: Land(green) and water(blue) are on separate layers

The white square is the "player"

I literally tried the whole day to get it working. I know it should but I can't tell why.

Here are some screenshots of my settings:

Image of the settings of the water tilemap Image of the settings of the water tilemap

Image of the settings of the player sprite Image of the settings of the player sprite

I've watched tons of tutorials and was told that there will be green grid lines where the collision boxes are.
I don't see those either


Unity version 2022.3.28f1

I tried reordering the components on the player sprite and the grid
For the player movement I use the velocity parameter on the rigidbody


Solution

  • My mistake was to leave the collider type of my water tiles to 'sprite'. When changing it to 'grid' my collisions worked as they should.