Quick answer: Godot 4 set_collision_layer_value indexing differently than the editor layer dropdown? Editor shows 1-32 (1-indexed); the function uses the same 1-indexed scheme - off-by-one bugs assume 0-indexed.

Layer 3 (third checkbox in editor) configured via set_collision_layer_value(2, true) - wrong layer.

Use 1-based indexing

body.set_collision_layer_value(3, true)

Editor's third layer checkbox = layer 3 in the API. The API matches the editor.

Or use bitmask directly

body.collision_layer = 1 << 2 for layer 3. Bitmask is 0-indexed; the per-layer helpers are 1-indexed. Don't mix.

Verify with the inspector

After setting, check the body's collision_layer in inspector. Confirms the bit is set correctly.

“Godot's collision API has two indexing schemes. The mismatch is the bug class.”

Establish a project convention: helpers use 1-based; raw bitmasks use 0-based. Write it in code review notes; the bug stops recurring.