Simple Collision between Tilemaplayer and CollisionShape2D is not working

Godot Version

4.3 stable

Question

Hey There i have a simple project, with a Characterbody2D and a Camera that follows it around. It has a Collisionshape2D attached to it. I have used the FastNoiseLite class to create a procedural generated map consisting of different tiles. The tiles for Grass and Sand are in one TileMapLayer and the ones for water are in a different one.
I have set the CharacterBody2D Collision Layer to 3 and its Mask to 1. I have set the TileMapLayer Collision Layer to 1 and its Mask to 1,2,3. The TileMapLayer with the Grass and Sand has no Layers or Masks.
In the TileMapLayer’s Tileset i have select the Water Tile and made sure the tileset with the Water has the right physics layer assigned.
I just want the player to not enter the water.

here are some screenshots: Imgur: The magic of the Internet

what am i doing wrong? Thanks in advance for any help :slight_smile:

I was able to get it to work myself. I did not use the move_and_slide() function and was rather setting the position by changing the x and y values of the Characterbody2D.

great job for fixing it by yourself

1 Like