Skip to content
Back to skills

Godot Physics

ASecurity

Godot physics bugs in 2D and 3D: body_entered never fires, layers and masks, tunnelling, raycasts that miss, RigidBody or CharacterBody.

  • 5 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added December 3, 2026
ai-agentspythongobashreactnodespring

Security analysis

A100/100

Pro scans all 6 files and shows the line behind each finding

Scanned December 3, 2026

npx -y skills add tipoLi5890/game-studio --skill godot-physics --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Godot Physics?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Godot Physics
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/tipoli5890-godot-physics/badge)](https://www.skillsdirectory.com/skills/tipoli5890-godot-physics)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: godot-physics
description: >-
  Godot physics bugs in 2D and 3D: body_entered never fires, layers and masks, tunnelling,
  raycasts that miss, RigidBody or CharacterBody.
---

# godot-physics — when a collision does not happen

Most physics bugs are a layer, a mask or a monitoring flag, and a short probe shows which.

## Situation → where to read

| Situation | Read |
|---|---|
| "`body_entered` never fires", "the pickup does nothing", "the trigger works once" | *Why a signal never fires* below, then probe the scene |
| Layers and masks: who detects whom, layer numbers against bits, naming layers | `reference/layers.md` |
| A fast bullet or a falling crate goes through a wall or a trigger | *Tunnelling* below |
| A raycast that misses, hits the shooter, or hits a trigger | `reference/queries.md` |
| Rigid, character, animatable or static body; pushing crates; moving platforms; pinning a rigid body | `reference/bodies.md` |
| GodotPhysics3D or Jolt; tick rate; deterministic headless physics | *The engine and the tick* below |
| Tile collision | `godot-tilemap` |

## Why a signal never fires

Each cause holds in 2D and 3D (under both 3D engines); the selftest runs each beside its fix:

| Cause | Fix |
|---|---|
| The area's `monitoring` is off | turn it on; an area that only needs to be found by others keeps it off and `monitorable` on |
| **The area's own mask** misses the body's layer (the body's mask holding the area's layer does not count) | put the body's layer in the **area's** `collision_mask` |
| `area_entered` from an area whose `monitorable` is off | `monitorable` on for the area being detected |
| Waiting for `body_entered` from an area (or `area_entered` from a body) | bodies arrive on `body_entered`, areas on `area_entered` |
| A `RigidBody2D`/`RigidBody3D` `body_entered` with `contact_monitor` off, **or** `max_contacts_reported` 0 | both: `contact_monitor = true` and `max_contacts_reported` ≥ 1 |
| A `CollisionShape2D`/`3D` with `disabled`, or no `shape` | enable it, give it a shape |
| A body faster than the area is thick (12000 px/s through a 4 px area: the area never fires, CCD on the body or not) | sweep a ray from the last position to the new one with `collide_with_areas` (`reference/queries.md`) |
| Setting `monitoring` inside its own `body_entered`: `ERROR: Function blocked during in/out signal. Use set_deferred("monitoring", true/false).` and the value does not change | `set_deferred("monitoring", false)` |
| Adding an area or body from inside a collision signal: `ERROR: Can't change this state while flushing queries. Use call_deferred() or set_deferred() ...` | `add_child.call_deferred(node)` |
| Reading `get_overlapping_bodies()` right after adding the area: empty | overlaps exist after the next physics tick; a body already inside gets `body_entered` then |
| A `CharacterBody2D` waiting for its own collision signal | it has none: read `get_slide_collision_count()` after `move_and_slide()` |

## Probe a scene

```bash
python3 scripts/physics_probe.py /path/to/project res://levels/rooftop_route.tscn
python3 scripts/physics_probe.py /path/to/project res://gate_room.tscn --ticks 300 --pairs
```

It runs `resources/collision_probe.gd` against the scene headless (by absolute path: nothing is
written into the project) and prints one `OBJECT` line per collision object (layer, mask,
monitoring, contact settings, enabled shapes), `PAIR a -> b` for every pair where a's mask holds
a layer of b (`one-way` when only one side does), `FIRED` with how often each connected signal
fired in N ticks, and a `FAIL` line for each connected signal that cannot fire as set up:
`monitoring-off`, `contact-monitor-off`, `no-shape`, `mask-empty`, `mask-direction`,
`not-monitorable`. Any finding or engine error is exit 2. Scripts with `class_name` need the
project imported once first. The probe can also be copied into the project and run with
`-s res://.../collision_probe.gd -- res://scene.tscn 120`.

A finding the probe cannot make: a body that is spawned later. A `NOTE` says when an area's mask
matches nothing in the scene; run a journey that spawns it (`godot-play-harness`).

## Tunnelling

A body moves a whole tick's distance at once. A crate at 12000 px/s moves 200 px per tick at 60
ticks and passes a 4 px wall without touching it.

- **2D**: `RigidBody2D.continuous_cd = CCD_MODE_CAST_RAY` stops it at the wall every time.
  `CCD_MODE_CAST_SHAPE` does not, for box, circle and capsule shapes at 3000 to 30000 px/s against
  4 and 20 px static walls; use the ray mode, or check the shape mode against your own case.
- **3D**: `RigidBody3D.continuous_cd = true` stops it, under GodotPhysics3D and Jolt. Under Jolt
  without CCD the body reports `body_entered` and still ends up past the wall: **judge
  tunnelling by position, never by the signal.**
- CCD is for bodies against bodies. A thin **area** misses a fast body whatever the body's CCD:
  sweep a ray from the last position each tick, or make the area deeper than speed × tick.
- A `CharacterBody2D` moved by `move_and_slide()` at the same 12000 px/s stops at the 4 px wall:
  the motion is swept. Writing `position` directly skips that.

## Layers and masks in one paragraph

A layer is what an object **is**; a mask is what it **looks for**. An area detects what its own
mask holds. A moving body reacts to what its own mask holds: when only A's mask holds B, A stops
and B does not move; when only B's mask holds A, A passes and B is pushed. A rigid body whose
mask lacks the floor falls through it whatever the floor's mask says. In scene text the values are
bits (`collision_mask = 36` is layers 3 and 6); in code use `set_collision_mask_value(3, true)`
with the 1-based layer number. Name the layers in `project.godot` and keep a table:
`reference/layers.md`.

## The engine and the tick

- **3D engine**: `physics/3d/physics_engine` is `"DEFAULT"`, `"GodotPhysics3D"` or `"Jolt Physics"`.
  A project that never sets it runs exactly like GodotPhysics3D. Every case in this
  skill's selftest behaves the same under both engines, but resting depths differ slightly (a box
  rests 0.01 m lower under GodotPhysics3D). Set it explicitly, so CI and every machine run the
  same engine.
- **Tick**: `physics/common/physics_ticks_per_second` (60). Physics code goes in
  `_physics_process`; queries too, since a body moved by setting `position` is found at its old
  place until the next tick.
- **Headless tests need `--fixed-fps 60`.** Without it a headless run renders frames as fast as it
  can, physics ticks follow wall-clock time, and `--quit-after` (which counts frames) ends a
  60-tick test after a handful of ticks, with exit 0 and no sentinel. With it, one frame is one
  tick and every run gives the same numbers.
- Physics interpolation and the camera: `godot-camera` → `reference/jitter.md`.

## Selftest

`python3 scripts/physics_probe.py --selftest` (needs `GODOT_BIN`) probes a rooftop scene with each
mis-set-up signal (5 findings) and the same scene corrected (0 findings, every signal fires once),
then runs each cause beside its fix in 2D and in 3D under both engines, tunnelling with and
without CCD, the one-way mask cases, pinning and pushing rigid bodies, the queries of
`reference/queries.md`, and `monitoring` changed or a collision object added inside a signal (the
engine error, then the deferred call).

## Discipline

- **Name the layers before the first collision.** A table of layer → what lives there → who
  looks for it, in `project.godot` (`layer_names/2d_physics/layer_1` ...) and in the design notes.
- **The detector's mask is the one that matters.** When a signal is silent, read the detector's
  mask first.
- **Change physics state from a collision signal only through `set_deferred` and
  `call_deferred`**: monitoring, shapes, and adding collision objects all print an `ERROR:` there.
- **Judge collisions by positions and counts**, not by "it looked fine": a probe or a journey
  prints both.
- **Every change ends with `godot-verify`.**

## Related skills

- Character motors, slopes, one-way platforms: `godot-2d-controller` · `godot-3d-controller`
- Tile collision layers: `godot-tilemap`
- Navigation for agents: `godot-3d-controller`
- The camera's spring arm and its mask: `godot-camera`
- Journeys that spawn bodies and assert on contacts: `godot-play-harness`

Files in this skill

  • SKILL.md8.2 KB
  • reference/bodies.md4.6 KB
  • reference/layers.md4.2 KB
  • reference/queries.md3.7 KB
  • resources/collision_probe.gd7.3 KB
  • scripts/physics_probe.py29.4 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in ai-agents →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.