Regarding the value for set_collision_layer()
... Looking at the docs, it's not very clear (at least, to me), but the value is a single integer value that's a bitmask. If you hover over the collision layer values in the inspector, it might make more sense.
For example, hovering over the Layer 1
box says Layer 1 | Bit 0 | Value 1
and hovering over Layer 3
says Layer 3 | Bit 2 | Value 4
.
To activate only those two layers via a call to set_collision_layer()
, you'd specify a value of 5
(the two reported values
added together (1 + 4).
So, just add the values for whatever layers you're trying to activate and pass that into set_collision_layer()
Regarding #2, your collision layer and mask values sound "odd" to me.
The Layer
values are the layers the object appears in or is a part of. The Mask
values are the layers the object will "scan" for collisions. Typically, I'd expect the object to be on a different layer than it's scanning for collisions...
That said, it really doesn't explain the results you describe...