+1 vote

· collisionlayer
This describes the layers that the object appears in. By default, all bodies are on layer 1.
· collision
mask
This describes what layers the body will scan for collisions. If an object isn’t in one of the mask layers, the body will ignore it. By default, all bodies scan layer 1.

As far as I understand, according to the documentation, if you test for collisions, for example using "moveandcollide", the system will report collisions with bodies that are in a collision layer that is in the collision mask of the object we are calling the function on.

However, that is not always true.

Collisions are also detected against an object that happens to be looking for a mask that the object that is checking for collisions is in.

For example, you can have an object that is in no layer, but is testing for the player mask. Then, the player (that of course is in the player mask), is going to collide against that object when executing moveandcollide.

Is this the intended behaviour?

If it is, that's not what I understand from the docs.

enter image description here

in Engine by (16 points)

EDIT: forums are confusing

2 Answers

0 votes
Best answer

Hi,
Yes I believe you are correct. Adding a collision detection from one object to another, is like you've done it in both. Don't add it to the collision layer.
Here's a good video about collision: Using Physics Layers and Masks in Godot 3.1 (tutorial)

by (2,047 points)
selected by

Thanks,

In that case, I think it should be corrected in the documentation. While searching around I found much confussion with this behaviour.

I'm really liking Godot as a tool, but bugs in very basic funtionality and misleading documentation are keeping me away from recommending it to other developers :-(

+1 vote

I ran into the same behavior. The docs state that the mask determines which bodies will be scanned for. I have a hurt/hit box system. If I set the mask for the hurtbox to nothing, but set the mask for the hitbox to scan for hurtboxes, then the hurtbox will trigger collisions even though it's mask is completely blank. If the documentation was correct I would expect that only the hitbox would trigger collisions since it is the body with the mask that scans for hurtboxes. The hurtboxes should not trigger any collisions if its mask is turned off.

The current behaviour basically says, if body A is scanning for body B, then body B will also scan for body A even though it is not set to do so.

This could lead to really confusing behavior if I set the mask of body A to scan for body B and the mask for body B to scan for body C. Then when body B experiences a collision, I would expect that it MUST be body C since that is what my mask is set to. But in fact it may be body A OR B, even though I told body B to only scan for body C.

by (16 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.