Godot Version
4.3
Question
Is there a way to tell the CharacterBody2d to only use a specific physics layer or collision mask when move_and_slide is called? I have a TileSet with a Platform layer and a Traps layer, and I really do not want the player to detect that traps are the floor or walls. Instead I want it to just capture the collision, and let me handle it in code.
As a workaround, I have attached an Area2d to my player and use that for detecting the collisions on the Traps. It works, but seems like there must be a way to do this.
Is it true that ANY mask on the Player that is used on a TileSet will trigger wall and floor events?
In the Character2D node, collisions, you will find collision mask and collision
layer(Collision Layer is where the node is, and Collision Mask is where it looks for objects to collide with), and if you are using a tileset there is a physics layer that contains collision layer and mask layer, you can set them to your liking.
Example:
Set player’s layer to 1 and mask to 2,3, now for the wall set layer to 2 and mask to 1, and set floor layer to 3 and mask to 1. In this case the player can collide with both floor and wall, but they can only collide with the player and not each other.
Hope that made sense.
That does make sense when using a separate mask for floor and walls, however what I would like to know is if it is possible to have a layer that does not treat the physics layer as a wall or floor. It seems like any masked layer, regardless of its use will affect the move_and_slide function.
In my example, I have a layer of tiles for traps. I dont want trap layer to affect physics, I do however want to be able to capture it as a collision.
Maybe I am missing something obvious here.