what is collision layer and collision mask?i dont understanded about it.

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

In the following cases, both will collide.
rigidbody.set_collision_mask (1)
staticbody.set_collision_layer (1)
In the following cases, both do not collide.
rigidbody.set_collision_mask (1)
staticbody.set_collision_mask (1)

I do not understand the meaning
Is there a simple example?

I already read here
https://forum.godotengine.org/4010/whats-difference-between-collision-layers-collision-masks
please hint

I understand.
Collision layer means just affiliation.
The collision mask is a specification of the colliding object!

bgegg | 2019-06-23 09:14

:bust_in_silhouette: Reply From: Xrayez

Collision Layer = "I can exist in different collision layers which essentially describe my collision inherent characteristics. I can have many such characteristics!

I can be a Fish, but then I can become a Frog, or both in some way, a Mutant!"


Collision Mask = "Given my own collision characteristics and unique individuality, I’m able to interact with other bodies having these specified characteristics.

I can’t mess with Sharks and can’t go through them, but I’m large enough to go past and eat Planktons, ez".

Note: if you go to Project Settings → Layer Names, you can set more readable names for layers, so it would start to make more sense.

Xrayez | 2019-06-22 12:59

:bust_in_silhouette: Reply From: Eric Ellingson

The collision layer describes what your current object is. The collision mask is what your current object is able to collide with.

Lets say you set up two different collision layers: Player and Enemy (configured like @Xrayez said in the project settings)

On your player node, you would set the collision layer to Player and the collision mask to Enemy. On your enemy node, you would set the collision layer to Enemy and the collision mask to Player. This would mean that both entities will detect collisions between each other.

You could alternatively only set the collision mask for the player node to Enemy, and not set anything on the enemy node, and I believe you would then only detect collisions via the player node.