+1 vote

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

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

I already read here
please hint

in Engine by (200 points)

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

2 Answers

0 votes

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".

by (1,377 points)

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.

+2 votes

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.

by (1,656 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.