agentleFS
Simone-TarantinoSimone-Tarantino/godot-superpowers/skills/setup-collision-layers/SKILL.md

setup-collision-layers

Skill2 starsChanged 6 months agoMITView on GitHub

Configure Godot 4.x physics collision layers and masks for 2D and 3D — sensible 11-layer scheme for player, enemies, environment, projectiles, pickups, triggers, hurtboxes, hitboxes. Edits project.godot.

The file

We split this skill into the rules it gives an agent

3 rules. About 0 are common, 2 are distinctive, and 1 is very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈2

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 1

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    If hits don't register:

    line 106
  2. Very specific:

    Verify both shapes have monitoring = true (Areas) or appropriate physics setup

    line 107
  3. Distinctive:

    Check shapes overlap visually (debug drawing on)

    line 109

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Setup Collision Layers

Configures Project Settings → Layer Names → 2D Physics and 3D Physics with a battle-tested 11-layer scheme that supports clean hurtbox/hitbox separation.

The scheme

BitNameUsed byMasks (collides with)
1WorldStaticBody2D/3D, TileMapLayer, terrain(passive — bodies on this layer don't actively scan)
2PlayerCharacterBody2D/3D playerWorld, Enemy, Pickup, Trigger
3EnemyEnemy CharacterBody / RigidBodyWorld, Player, EnemyHurtbox
4PlayerProjectileBullets / abilities owned by playerWorld, Enemy, EnemyHurtbox
5EnemyProjectileBullets / abilities owned by enemiesWorld, Player, PlayerHurtbox
6PickupCoins, items, powerupsPlayer
7TriggerArea-based events, doors, checkpointsPlayer (also Enemy if needed)
8PlayerHurtboxArea on player that takes damageEnemyHitbox, EnemyProjectile
9PlayerHitboxArea on player that deals damageEnemyHurtbox
10EnemyHurtboxArea on enemy that takes damagePlayerHitbox, PlayerProjectile
11EnemyHitboxArea on enemy that deals damagePlayerHurtbox

Hitbox rule: a hitbox sits on its own layer and masks the opposing hurtbox layer. Never the reverse.

Apply to project.godot

Append (or merge into existing [layer_names] section):

[layer_names]

2d_physics/layer_1="World"
2d_physics/layer_2="Player"
2d_physics/layer_3="Enemy"
2d_physics/layer_4="PlayerProjectile"
2d_physics/layer_5="EnemyProjectile"
2d_physics/layer_6="Pickup"
2d_physics/layer_7="Trigger"
2d_physics/layer_8="PlayerHurtbox"
2d_physics/layer_9="PlayerHitbox"
2d_physics/layer_10="EnemyHurtbox"
2d_physics/layer_11="EnemyHitbox"

3d_physics/layer_1="World"
3d_physics/layer_2="Player"
3d_physics/layer_3="Enemy"
3d_physics/layer_4="PlayerProjectile"
3d_physics/layer_5="EnemyProjectile"
3d_physics/layer_6="Pickup"
3d_physics/layer_7="Trigger"
3d_physics/layer_8="PlayerHurtbox"
3d_physics/layer_9="PlayerHitbox"
3d_physics/layer_10="EnemyHurtbox"
3d_physics/layer_11="EnemyHitbox"

Helper constants (optional but recommended)

Add scripts/collision_layers.gd:

class_name CollisionLayers
extends RefCounted

## Bit constants for layer set/get via code. Use as flags:
##     hitbox.collision_layer = CollisionLayers.PLAYER_HITBOX
##     hitbox.collision_mask = CollisionLayers.ENEMY_HURTBOX

const WORLD := 1 << 0
const PLAYER := 1 << 1
const ENEMY := 1 << 2
const PLAYER_PROJECTILE := 1 << 3
const ENEMY_PROJECTILE := 1 << 4
const PICKUP := 1 << 5
const TRIGGER := 1 << 6
const PLAYER_HURTBOX := 1 << 7
const PLAYER_HITBOX := 1 << 8
const ENEMY_HURTBOX := 1 << 9
const ENEMY_HITBOX := 1 << 10

Configuration cheatsheet for common nodes

Nodecollision_layercollision_mask
Player CharacterBodyPlayerWorld, Enemy, Pickup, Trigger
Enemy CharacterBodyEnemyWorld, Player
Wall / floor StaticBodyWorld(none)
Player bulletPlayerProjectileWorld, Enemy, EnemyHurtbox
Enemy bulletEnemyProjectileWorld, Player, PlayerHurtbox
Coin AreaPickup(none — Player's mask handles it)
Door trigger AreaTrigger(none)
Player Hurtbox AreaPlayerHurtboxEnemyHitbox, EnemyProjectile
Player Hitbox Area (sword)PlayerHitboxEnemyHurtbox
Enemy Hurtbox AreaEnemyHurtboxPlayerHitbox, PlayerProjectile
Enemy Hitbox Area (claw)EnemyHitboxPlayerHurtbox

Debugging

Enable Debug → Visible Collision Shapes while running. Color collisions to verify layer / mask combinations are correct.

If hits don't register:

  1. Verify both shapes have monitoring = true (Areas) or appropriate physics setup
  2. Confirm layer/mask: emitter on its own layer, mask = receiver's layer
  3. Check shapes overlap visually (debug drawing on)
  4. For Areas: check monitorable = true on the receiver

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.