
godot-2d-physics
Expert patterns for Godot 2D physics including collision layers/masks, Area2D triggers, raycasting, and PhysicsDirectSpaceState2D queries. Use when implementing collision detection, trigger zones, line-of-sight systems, or manual physics queries. Trigger keywords: CollisionShape2D, CollisionPolygon2D, collisionlayer, collisionmask, setcollisionlayervalue, setcollisionmaskvalue, Area2D, bodyentered, bodyexited, RayCast2D, forceraycastupdate, PhysicsPointQueryParameters2D, PhysicsShapeQueryParameters2D, directspacestate, moveandcollide, moveandslide.
- Installs
- 519
- Last 24h
- —
- Trending rank
- —
- Security
- Not audited
Install
Works with every agent the skills CLI supports.
npx skills add https://github.com/thedivergentai/game-dev-agentic-skills --skill godot-2d-physics- 01
Install
Run the command in your project. The CLI asks which agents to install for.
- 02
Describe the task
Ask your agent for something this skill covers. It loads godot-2d-physics automatically when relevant.
- 03
Review the result
The agent follows the SKILL.md steps, scripts and references bundled with the skill.
SKILL.md
The instructions your agent reads when the skill is triggered.
2D Physics
Expert guidance for collision detection, triggers, and raycasting in Godot 2D.
NEVER Do
- NEVER scale
CollisionShape2Dnodes — Use the shape handles in the editor, NOT the Node2D scale property. Scaling causes unpredictable physics behavior and incorrect collision normals [12]. - NEVER confuse
collision_layerwithcollision_mask— Layer = "What AM I?", Mask = "What do I DETECT?". Setting both to the same value is usually wrong [13]. - NEVER multiply velocity by delta when using
move_and_slide()—move_and_slide()automatically includes timestep. Only multiply gravity/acceleration by delta [14]. - NEVER forget
force_raycast_update()for manual mid-frame raycasts — Raycasts update once per physics frame. If you change target_position, you MUST force an update [15]. - NEVER use
get_overlapping_bodies()every frame — It is expensive. Cache results withbody_entered/body_exitedsignals instead [16]. - NEVER modify
RigidBody2Dstate directly in_process— Use_integrate_forces()for safe, synchronized access toPhysicsDirectBodyState2D[17, 411]. - NEVER move
PhysicsBody2Dnodes in_process()— Use_physics_process(). Moving bodies outside the physics step causes stutter and unreliable collision detection. - NEVER use
RigidBody2Dfor 1000+ simple entities — UsePhysicsServer2Dto bypass node overhead for massive performance gains (Swarms/Bullets) [18, 397]. - NEVER use
Area2Dfor high-frequency blocking (Bullets) — Area signals can be delayed. Usemove_and_collide()orShapeCast2Dfor frame-perfect results [19]. - NEVER ignore 'Physics Jitter' on high-refresh monitors — Enable Physics Interpolation to prevent micro-stutter in motion [21, 400].
- NEVER scale collision shapes directly at runtime — It causes major instability. Resize the shape resource (size/radius) instead.
- NEVER use
set_deferredfor immediate physics transform logic — It happens at the end of the frame. Useforce_raycast_update()orPhysicsServer2Dinstead. - NEVER leave Continuous CD (CCD) enabled for slow objects — It adds significant CPU overhead. Reserve it for high-speed projectiles to prevent tunneling.
- NEVER use a single collision layer for all tiles/entities — Separate layers (Ground, Walls, Enemies) to allow selective filtering via masks.
- NEVER forget to free
PhysicsServer2DRIDs manually — They are not garbage collected and will leak memory permanently.
Available Scripts
MANDATORY: Read the script matching your workflow branch before coding. Query/Area cookbook samples live in scripts — not in this body.
Workflow router (MANDATORY / Do NOT Load)
| Branch | Load | Do NOT Load |
|---|---|---|
| Layer/mask matrix setup | collision_bitmask_helper.gd or collision_setup.gd; matrix policy → collision_layer_matrix_manager.gd | Swarm / CCD scripts |
| LOS / vision cones | raycast_vision_stack.gd (+ physics_direct_query.gd for nodeless rays) | shapecast_aoe*.gd, physics_server_swarm.gd |
| AOE / melee volume | Prefer shapecast_aoe.gd (faction mask); ground/volume sensing → shapecast_aoe_detection.gd | Area2D spam + lava DoT tutorials; do not load both shapecast scripts for the same feature |
| Hitscan / point pick / one-shot shape | physics_queries.gd (canonical). Specialists: physics_direct_space_query.gd (LOS bool), raycast_hit_prediction.gd | Re-load all three query helpers at once |
| Bullet hell / 1000+ bodies | MANDATORY physics_server_swarm.gd (+ physics_server_direct_body.gd for RID shapes) | Per-bullet Area2D / RigidBody2D nodes |
| High-speed tunneling | continuous_collision_detection.gd + substepping_logic.gd | CCD on slow props |
| RigidBody safe mutate | safe_rigidbody_state.gd (_integrate_forces) | Direct transform writes in _process |
| Custom CharacterBody forces | custom_physics_2d.gd | custom_physics.gd (that file is RigidBody _integrate_forces) |
| Gravity zones | custom_gravity_area.gd (Area override) or custom_gravity_override.gd (character weight/zones) | Both unless you need Area + character paths |
| Overlap signal spam | collision_debouncer.gd | Polling get_overlapping_bodies every frame |
| Compound multi-shape RID | compound_body_sync.gd | Multiple nodes for one logical body |
| Debug contact normals | collision_visual_debugger.gd | Visible collision menu insufficient |
| High-refresh jitter | Prefer jitter_interpolation_fix.gd | physics_interpolation_smoothing.gd (legacy/manual; only if built-in interpolation is unavailable) |
| Precision bounce / slide | move_and_collide_precision.gd | — |
| Batch static movers | performance_batch_mover.gd | — |
| Query result cache | physics_query_cache.gd | Duplicate space queries same frame |
Canonical vs overlap (dedupe guide)
- ShapeCast AOE: load
shapecast_aoe.gdfor combat AOE;shapecast_aoe_detection.gdonly for grounded/volume checks — never both for one feature. - Space queries: start with
physics_queries.gd; addphysics_direct_query.gd/physics_direct_space_query.gdonly if that specialist matches. - Custom physics: CharacterBody →
custom_physics_2d.gd; RigidBody integrate →custom_physics.gd. - Interpolation:
jitter_interpolation_fix.gdwins overphysics_interpolation_smoothing.gd.
Script index
- collision_setup.gd / collision_bitmask_helper.gd / collision_layer_matrix_manager.gd
- physics_queries.gd / physics_direct_query.gd / physics_direct_space_query.gd / physics_query_cache.gd
- raycast_vision_stack.gd / raycast_hit_prediction.gd
- shapecast_aoe.gd / shapecast_aoe_detection.gd
- physics_server_swarm.gd / physics_server_direct_body.gd
- continuous_collision_detection.gd / substepping_logic.gd
- safe_rigidbody_state.gd / custom_physics.gd / custom_physics_2d.gd
- custom_gravity_area.gd / custom_gravity_override.gd
- collision_debouncer.gd / jitter_interpolation_fix.gd
- compound_body_sync.gd / collision_visual_debugger.gd
- move_and_collide_precision.gd / performance_batch_mover.gd
- physics_interpolation_smoothing.gd — legacy; prefer jitter fix script
Decision Tree: Collision Detection Methods
| Use Case | Method | Why / script |
|---|---|---|
| Continuous trigger zone | Area2D + signals | Memory of occupants; debounce with collision_debouncer.gd |
| One-time pickup | Area2D + queue_free on enter | Simple cleanup |
| Line-of-sight | RayCast2D / direct ray | raycast_vision_stack.gd or physics_direct_query.gd |
| Click-to-select | PhysicsPointQueryParameters2D | physics_queries.gd |
| AOE spell / melee volume | ShapeCast2D / shape query | shapecast_aoe.gd (not Area signal lag) |
| Instant-hit weapon | PhysicsRayQueryParameters2D | physics_queries.gd / raycast_hit_prediction.gd |
| Platformer ground / ledge | Ray or ShapeCast down | CharacterBody skill + shapecast_aoe_detection.gd |
| 1000+ projectiles | PhysicsServer2D RIDs | MANDATORY physics_server_swarm.gd |
Mental model (keep short)
- Layer = who I am; Mask = who I detect. Bitmask cookbook → collision-layers-masks.md.
- Area2D with multiple shapes fires
body_enteredonce per shape — dedupe with a Set/dict or collision_debouncer.gd. - Mid-frame ray/shape changes require
force_raycast_update()/force_shapecast_update(). _readyphysics queries are false until after a physics frame (await get_tree().physics_frame).CharacterBody2Dships withcollision_layer = 0— Areas won't see it until you set a layer.- Free PhysicsServer RIDs yourself — they are not GC'd.
Deep recipes (on demand)
| Topic | Reference / script |
|---|---|
| Layer/mask patterns | collision-layers-masks.md |
| Area2D, raycast, shape queries | area2d-and-queries.md |
| Compound RID bodies | compound_body_sync.gd |
| Contact normal debug draw | collision_visual_debugger.gd |
Reference
Progressive disclosure: open Official Documentation links only when researching a specific API; load Related Skills when routing work to a peer domain — do not preload the whole lattice.
Official Documentation
- Physics introduction — Collision layers vs masks, body types, and the mental model every 2D setup depends on.
- Collision shapes (2D) — Correct shape sizing and why scaling
CollisionShape2Dnodes breaks normals and contacts. - Using CharacterBody2D —
move_and_slide/move_and_collide, floor detection, and kinematic movement contracts. - Using Area2D — Trigger monitoring, overlap signals, and space/gravity overrides for zones.
- Ray-casting —
RayCast2DvsPhysicsDirectSpaceState2Drays, exclusions, and mid-frameforce_raycast_update. - RigidBody — Safe rigid-body control via
_integrate_forces/PhysicsDirectBodyState2Dinstead of fighting the solver in_process. - Troubleshooting physics issues — Tunneling, jitter, one-way platforms, and common layer/mask misconfigurations.
- Physics interpolation introduction — Why fixed physics ticks stutter on high-refresh displays and when interpolation fixes it.
- PhysicsServer2D — RID-based body/shape APIs for swarm-scale 2D physics without SceneTree overhead.
- PhysicsDirectSpaceState2D — Point, ray, and shape queries for LOS, AOE, and click-picking without permanent query nodes.
- ShapeCast2D — Volume casts for frame-perfect melee/AOE detection when
Area2Dsignal lag is unacceptable.
Related Skills
Prerequisites
- godot-project-foundations — Project Settings layer names, physics ticks, and default gravity must be set before layer/mask matrices stay sane.
- godot-gdscript-mastery — Bitmask enums, typed dictionaries for overlap sets, and
_physics_processdiscipline underpin every pattern here. - godot-signal-architecture —
body_entered/body_exitedwiring and debounce patterns need clean signal ownership to avoid spam.
Complements
- godot-characterbody-2d — Coyote time, jump buffers, and one-way platforms sit on top of the collision contracts this skill defines.
- godot-raycasting-queries — Deeper query parameter recipes (exclusions, masks, shape casts) when vision/hitscan systems grow beyond basics.
- godot-tilemap-mastery — Tile physics layers and one-way tile collisions must match the same layer matrix used by bodies and areas.
- godot-input-handling — Physics-step input sampling and vsync/latency choices couple tightly with
move_and_slidefeel. - godot-physics-3d — Parallel 3D body/query concepts when porting or sharing layer policy across dimensions.
- godot-performance-optimization — Profiling and batching guidance when
PhysicsServer2Dswarms or query caches become bottlenecks. - godot-debugging-profiling — Visible collision shapes, contact normals, and frame-time traps when diagnosing jitter or missed hits.
Downstream / consumers
- godot-combat-system — Hitboxes/hurtboxes are
Area2D+ layer/mask products; damage timing inherits overlap and CCD choices. - godot-genre-platformer — Platformer feel (floors, ledges, one-ways) consumes CharacterBody2D + collision setup from this domain.
- godot-navigation-pathfinding — Agents still need physics layers for blockers and LOS; keep nav meshes and collision worlds consistent.
- godot-monte-carlo-balancer — Jump windows, projectile speed/CCD, gravity, and hitbox size directly change win-rate and difficulty curves; simulate those physics knobs instead of guessing.
Master
- godot-master — Library router and mirrored entry point for discovering 2D physics alongside sibling domains.
FAQ
What does the godot-2d-physics skill do?
Expert patterns for Godot 2D physics including collision layers/masks, Area2D triggers, raycasting, and PhysicsDirectSpaceState2D queries. Use when implementing collision detection, trigger zones, line-of-sight systems, or manual physics queries. Trigger keywords: CollisionShape2D, CollisionPolygon2D, collisionlayer, collisionmask, setcollisionlayervalue, setcollisionmaskvalue, Area2D, bodyentered, bodyexited, RayCast2D, forceraycastupdate, PhysicsPointQueryParameters2D, PhysicsShapeQueryParameters2D, directspacestate, moveandcollide, moveandslide.
How do I install godot-2d-physics?
Run npx skills add https://github.com/thedivergentai/game-dev-agentic-skills --skill godot-2d-physics in your project. The skills CLI detects the agents you use and copies the skill into the right folder. For Claude Code you can also place the skill folder at ~/.claude/skills/godot-2d-physics/ (personal) or .claude/skills/godot-2d-physics/ (project).
Which AI agents can use godot-2d-physics?
Any agent that supports the open Agent Skills format (a folder with a SKILL.md file), including Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, Windsurf, Cline, OpenCode and more.
Is godot-2d-physics safe to install?
No partner security audit is available yet. Skills can run commands and scripts, so read the SKILL.md and any bundled files before installing.
Who maintains godot-2d-physics?
It is published by thedivergentai in thedivergentai/game-dev-agentic-skills. It has 519 recorded installs.
More from thedivergentai/game-dev-agentic-skills
godot-master
thedivergentai/game-dev-agentic-skills
Consolidated expert library for professional Godot 4.7+ game and application development. Orchestrates 92 Domain Skills through architectural workflows, anti-pattern catalogs, performance budgets, and Server API patterns. Use when: (1) starting a new Godot project, (2) designing game or app architecture, (3) building entity/component systems, (4) debugging performance or physics issues, (5) choosing between 2D/3D approaches, (6) implementing multiplayer, (7) optimizing draw calls or script time, (8) porting between platforms, (9) migrating from 4.6 to 4.7. Primary entry point for ALL Godot development tasks. Keywords: Godot 4.7, AreaLight3D, HDR, Asset Store, godot-master.
godot-shaders-basics
thedivergentai/game-dev-agentic-skills
Expert Godot shader patterns for batch-safe hitflash, alpha-scissor foliage/dissolve, screenspace postFX, depth reconstruction, triplanar, and instance uniforms — not first-shader tutorials. Trigger on draw-call batching breaks, discard vs depth-prepass, foliage shadows, post-process quads, or world-position FX. Keywords: instance uniform, ALPHASCISSOR, hintscreentexture, hintdepthtexture, global uniform, sampler2DArray, canvasitem, spatial, post-processing.
godot-2d-animation
thedivergentai/game-dev-agentic-skills
Expert patterns for 2D animation in Godot using AnimatedSprite2D and skeletal cutout rigs. Use when implementing sprite frame animations, procedural animation (squash/stretch), cutout bone hierarchies, or frame-perfect timing systems. Trigger keywords: AnimatedSprite2D, SpriteFrames, animationfinished, animationlooped, framechanged, frameprogress, setframeandprogress, cutout animation, skeletal 2D, Bone2D, procedural animation, animation state machine, advance(0).
godot-ui-theming
thedivergentai/game-dev-agentic-skills
Expert blueprint for UI themes using Theme resources, StyleBoxes, custom fonts, and theme overrides for consistent visual styling. Covers StyleBoxFlat/Texture, theme inheritance, dynamic theme switching, and font variations. Use when implementing consistent UI styling OR supporting multiple themes. Keywords Theme, StyleBox, StyleBoxFlat, addthemeoverride, font, theme inheritance, dark mode.
godot-gdscript-mastery
thedivergentai/game-dev-agentic-skills
Expert GDScript landmine guidance: static typing opcodes, signal-up/call-down, %UniqueName/@onready lifecycle, Callable bind/unbind, await sequences, typed collections, and safe Dictionary iteration. Use for code review, refactoring hot paths, or project standards. Trigger keywords: statictyping, signalarchitecture, uniquenodes, @onready, classname, signalupcalldown, Callable.bind, typedcollections, awaitsequence.
godot-particles
thedivergentai/game-dev-agentic-skills
Expert blueprint for GPU particle systems (explosions, magic effects, weather, trails) using GPUParticles2D/3D, ParticleProcessMaterial, gradients, sub-emitters, and custom shaders. Use when creating VFX, environmental effects, or visual feedback. Keywords GPUParticles2D, ParticleProcessMaterial, emissionshape, colorramp, subemitter, oneshot.
Popular education & science skills
teach
mattpocock/skills
Teach the user a new skill or concept, within this workspace.
scaffold-exercises
mattpocock/skills
Create exercise directory structures with sections, problems, solutions, and explainers that pass linting. Use when user wants to scaffold exercises, create exercise stubs, or set up a new course section.
paper-context-resolver
lllllllama/rigorpilot-skills
Rigor Paper Context helper for README-first deep learning repo reproduction. Use only when the README and repository files leave a narrow reproduction-critical gap and the task is to resolve a specific paper detail such as dataset split, preprocessing, evaluation protocol, checkpoint mapping, or runtime assumption from primary paper sources while recording conflicts. Do not use for general paper summary, repo scanning, environment setup, command execution, title-only paper lookup, or replacing README guidance by default.
caveman-learn
juliusbrussee/caveman
Act on a Caveman learn report - review the ranked token sinks, apply cost-lowering fixes with per-edit consent, and report what those fixes returned. Use when asked to lower an agent's token cost, what caveman has saved, to trim a heavy CLAUDE.md, or to offload re-pasted context into cavemem.
gsap-plugins
greensock/gsap-skills
Official GSAP skill for GSAP plugins — registration, ScrollToPlugin, ScrollSmoother, Flip, Draggable, Inertia, Observer, SplitText, ScrambleText, SVG and physics plugins, CustomEase, EasePack, CustomWiggle, CustomBounce, GSDevTools. Use when the user asks about a GSAP plugin, scroll-to, flip animations, draggable, SVG drawing, or plugin registration.
teach-impeccable
pbakaus/impeccable
DEPRECATED: Use /impeccable teach instead. This command has been folded into the impeccable skill.