Agent skill

Godot Raycasting Queries

by thedivergentai in thedivergentai/GD-Agentic-Skills

Expert blueprint for physics queries using RayCast, ShapeCast, and DirectSpaceState.

LGPL-3.0Auto-check passedGame Development

Install Godot Raycasting Queries

skills CLI
$ npx skills add thedivergentai/GD-Agentic-Skills --skill godot-raycasting-queries -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install thedivergentai/GD-Agentic-Skills godot-raycasting-queries --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/thedivergentai/GD-Agentic-Skills.git skills-src && mkdir -p .claude/skills && cp -r skills-src/skills/godot-raycasting-queries .claude/skills/godot-raycasting-queries && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
godot-raycasting-queries
GitHub stars
821
Token cost
~3.3k tokens
SKILL.md length
1,042 words
Files
13 (incl. scripts, references)
Skills in repo
98
Repo updated
First seen
Licence
LGPL-3.0

At a glance

Expert blueprint for physics queries using RayCast, ShapeCast, and DirectSpaceState.

  • Implementing projectiles
  • SKILL.md covers Available Scripts, NEVER Do in Physics Queries, Query-Type Decision Table and 3D Mouse Picking Example, plus 3 more sections
  • Terrain grounding

What it does

Godot Raycasting Queries is an agent skill from thedivergentai/GD-Agentic-Skills. Expert blueprint for physics queries using RayCast, ShapeCast, and DirectSpaceState. Covers hit detection, volume overlap, mouse picking, and high-performance server-side intersection queries. Use when implementing projectiles, LOS, terrain grounding, or AI sensors. Keywords raycast, shapecast, directspacestate, intersectray, intersectshape, PhysicsRayQueryParameters, collision mask, mouse picking.

Its SKILL.md is about 3.3k tokens, which your agent loads only when the skill is triggered. The skill folder holds 14 other files, including scripts and reference files (for example `references/migration-notes.md` and `references/query-elite-patterns.md`).

It sits in Game Development, covering Game development and Backend development. It works with Godot. The repository describes itself as: The official "Long-Term Memory" for Godot 4.7+ AI Agents. A high-density library of 99 expert skills and 27 genre blueprints, providing audited, strictly typed GDScript patterns… The licence is LGPL-3.0.

When your agent uses it

  • Implementing projectiles
  • Terrain grounding

Example prompts

  • “/godot-raycasting-queries”

What it can do on your machine

Read from SKILL.md and the folder at commit 4c4d0ff. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    Ships 10 files in scripts/, which the agent can run.

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    Links to these hosts (documentation or services it may open):

    • docs.godotengine.org

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Godot Raycasting Queries loads about 3.3k tokens when it runs, and up to ~4.8k if it reads all its reference files. Until then it costs about 108 tokens; SKILL.md has 1,042 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~108
When it runs · the whole SKILL.md, loaded when a task matches
~3.3k
With references · SKILL.md plus every file in references/, read only if the agent opens them
~4.8k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); the scripts in this folder are not scanned.

SKILL.md

The full file from thedivergentai/GD-Agentic-Skills at commit 4c4d0ff, republished under its LGPL-3.0 licence (© thedivergentai). 1,042 words, ~3,300 tokens.

Download SKILL.mdSave it as .claude/skills/godot-raycasting-queries/SKILL.md (or your agent's skills folder). This skill also uses 12 other files; get the full folder from GitHub.
name
godot-raycasting-queries
description
Expert blueprint for physics queries using RayCast, ShapeCast, and DirectSpaceState. Covers hit detection, volume overlap, mouse picking, and high-performance server-side intersection queries. Use when implementing projectiles, LOS, terrain grounding, or AI sensors. Keywords raycast, shapecast, direct_space_state, intersect_ray, intersect_shape, PhysicsRayQueryParameters, collision mask, mouse picking.

Available Scripts

MANDATORY for common paths — read before implementing (do not improvise query APIs from memory):

Do NOT Load every script below for one task. Open only the row that matches the decision table.

direct_space_state_raycast.gd

Expert usage of PhysicsDirectSpaceState2D/3D for bypassing node-based overhead in high-frequency queries.

shapecast_ground_detection.gd

Reliable ground/footing detection using volume-based ShapeCast instead of thin rays.

multiple_hit_piercing_ray.gd

Implementing piercing projectiles that detect and return multiple hits in a single line.

field_of_view_scanner.gd

AI sensor logic using a fan of raycasts to detect targets within a FOV cone.

raycast_reflection_logic.gd

Calculating bounces for lasers or bullets using collision normal reflection.

point_in_shape_query.gd

Checking for overlapping physics bodies at a single point (Explosion epicenters).

rest_info_3d_stuck_fix.gd

Using get_rest_info to detect stuck objects and resolve overlaps immediately.

mouse_pick_3d_query.gd

Converting 2D screen coordinates to 3D world rays for point-and-click interaction.

water_buoyancy_surface_calc.gd

Finding water surface height for buoyancy systems using high-to-low raycasting.

query_exclusion_optimization.gd

Optimizing performance by excluding specific RIDs (Resource IDs) from intersection checks.

NEVER Do in Physics Queries

  • NEVER access direct_space_state outside of _physics_process() — The physics space can be locked or running on a separate thread; querying it in _process() is unsafe [1, 2].
  • NEVER use ShapeCast when a thin RayCast is sufficient — Volume queries are significantly more expensive. Default to rays unless you need volumetric detection [3, 4].
  • NEVER assume results return CollisionObject nodes — CSG shapes, GridMap, and TileMapLayer return themselves, not a generic physics body [5, 6].
  • NEVER assume RayCast nodes update instantly — They update once per physics frame. If you move a node and query it immediately, you MUST call force_raycast_update() [3, 9].
  • NEVER use complex visual meshes for physics queries — GPU-only data requires expensive thread locking to parse. Use simplified primitive collision shapes [10, 11].
  • NEVER iterate results to find the first valid hit — Use collision_mask and collision_layer to filter queries at the server level for maximum performance.
  • NEVER forget to exclude the caster — A ray starting from the center of a character will hit the character itself. Use query.exclude = [self.get_rid()] [20].
  • NEVER use rays for small, fast detection areas — Rays can "tunnel" through thin walls if the frame rate drops. Use cast_motion or high-frequency stepping for bullets.
  • NEVER query 1000+ rays individually in GDScript — Batch your queries or use the PhysicsServer directly in C++ if you reach extreme query counts.
  • NEVER ignore the result.rid — RIDs are the fastest way to identify and exclude objects in subsequent queries, bypassing node-path lookups [20].

Query-Type Decision Table

Pick the cheapest API that answers the question. Always pair rays/shapes with RID exclude + masks (query_exclusion_optimization.gd).

NeedPreferCostWhenScript
Persistent sensor in the scene (ledge, aim assist debug)RayCast2D/RayCast3D nodeLow–medFew casts; OK waiting one physics frame (or force_raycast_update())Scene node + NEVER rules
Hitscan / LOS / one-shot mid-frame rayPhysicsDirectSpaceState*.intersect_rayLowHigh frequency, no permanent nodeMANDATORY direct_space_state_raycast.gd
Footing, thick walls, melee volumeShapeCast* / intersect_shapeMed–highThin ray tunnels or misses volumeMANDATORY shapecast_ground_detection.gd
Explosion / occupancy at a pointintersect_pointLow–medEpicenter overlap listpoint_in_shape_query.gd
Stuck / penetration resolveget_rest_infoMedOverlap recoveryrest_info_3d_stuck_fix.gd
Pierce / multi-hit along a lineRepeated intersect_ray + exclude RIDsMedProjectiles that keep goingmultiple_hit_piercing_ray.gd
Screen → world clickCamera project + intersect_rayLowPickingmouse_pick_3d_query.gd

3D Mouse Picking Example

gdscript
func screen_point_to_ray():
    var space_state = get_world_3d().direct_space_state
    var mouse_pos = get_viewport().get_mouse_position()
    
    var origin = project_ray_origin(mouse_pos)
    var end = origin + project_ray_normal(mouse_pos) * 2000
    
    var query = PhysicsRayQueryParameters3D.create(origin, end)
    var result = space_state.intersect_ray(query)
    
    if result:
        return result.collider
    return null

Expert WHY (query timing & LOS)

  • Physics step only — direct_space_state in _physics_process, not _process.
  • Self-hit — query.exclude = [get_rid()] on rays from character center.
  • NavMesh LOS — physics ray ≠ carved nav hole; path.size() == 2 on NavigationServer3D.map_get_path for strict mesh LOS (see deep dive).
  • Surface types — collider.get_meta(&"surface_type") beats class/group checks for decals/footsteps.
  • Compute GPU rays — out of scope; not a drop-in for gameplay intersect_ray.

Deep dive (load on demand)

NavMesh LOS validator, surface metadata, picking baseline, tunneling notes — references/query-elite-patterns.md.

Show full SKILL.md (419 more words)Show less

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
  • Ray-casting — Node RayCast* vs PhysicsDirectSpaceState* queries, result dictionaries, and exclude to avoid self-hits.
  • Physics introduction — Collision layers/masks that filter every ray, shape, and point query at the physics server.
  • Collision shapes (3D) — Why queries need primitive/convex shapes instead of visual meshes for reliable, cheap intersections.
  • PhysicsDirectSpaceState3D — intersect_ray / intersect_shape / intersect_point / get_rest_info / cast_motion contracts for mid-frame space queries.
  • PhysicsDirectSpaceState2D — 2D twin of direct space queries for LOS, hitscan, and point epicenters without permanent cast nodes.
  • PhysicsRayQueryParameters3D — Mask, exclude RIDs, hit_from_inside, and collide-with flags for reusable ray parameter objects.
  • PhysicsShapeQueryParameters3D — Shape RID + transform setup for volume casts, rest info, and stuck-overlap resolution.
  • PhysicsPointQueryParameters3D — Point-in-shape overlap lists for explosion epicenters and occupancy checks.
  • RayCast3D — Scene-tree cast nodes, collision exceptions, and when force_raycast_update() is required after moving.
  • ShapeCast3D — Volume casts and force_shapecast_update() for footing/melee detection that thin rays miss.
  • Camera3D — project_ray_origin / project_ray_normal for screen-to-world picking rays from the active camera.
  • Mouse and input coordinates — Viewport mouse position vs canvas/world space before building a pick ray.
Prerequisites
  • godot-project-foundations — Named physics layers and tick settings must exist before query masks and water/ground layer bits stay coherent.
  • godot-gdscript-mastery — Typed query parameters, RID arrays, and _physics_process-only space access are language-level contracts this skill depends on.
  • godot-2d-physics — 2D body/area layer matrices and when to prefer RayCast2D nodes vs direct space state for sensors.
Complements
  • godot-physics-3d — 3D body types, CCD, and collision setup that determine what your rays and shape casts can actually hit.
  • godot-characterbody-2d — Grounding, ledges, and coyote-time feel often consume ShapeCast/ray footing results from this domain.
  • godot-input-handling — Physics-step click/aim sampling couples with mouse-pick rays and hitscan timing.
  • godot-navigation-pathfinding — Physics LOS vs NavMesh path-straightness checks; keep obstacle carve and collision worlds consistent.
  • godot-ai-navigation — FOV fans and vision sensors feed AI perception stacks that still need correct query masks/exclusions.
  • godot-performance-optimization — Budgeting hundreds of rays, reusing query params, and knowing when node casts become SceneTree overhead.
  • godot-debugging-profiling — Visualizing cast lines/shapes and diagnosing missed hits from mask, exclude, or update-timing mistakes.
Downstream / consumers
  • godot-combat-system — Hitscan, piercing rays, and melee volumes resolve damage from query results produced here.
  • godot-genre-shooter — Hitscan weapons, bullet pierce, and aim assist consume exclusion/mask recipes and multi-hit pierce loops.
  • godot-monte-carlo-balancer — View distance, FOV ray counts, pierce max-hits, and query tick rate change fairness and difficulty; simulate those knobs instead of guessing.
Master
  • godot-master — Library router and mirrored entry point for discovering raycasting/query patterns alongside sibling domains.

© thedivergentai, LGPL-3.0. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

SKILL.md and 12 other files (scripts, references) in skills/godot-raycasting-queries of thedivergentai/GD-Agentic-Skills.

  • SKILL.md
  • references/migration-notes.md
  • references/query-elite-patterns.md
  • scripts/direct_space_state_raycast.gd
  • scripts/field_of_view_scanner.gd
  • scripts/mouse_pick_3d_query.gd
  • scripts/multiple_hit_piercing_ray.gd
  • scripts/point_in_shape_query.gd
  • scripts/query_exclusion_optimization.gd
  • scripts/raycast_reflection_logic.gd
  • scripts/rest_info_3d_stuck_fix.gd
  • scripts/shapecast_ground_detection.gd
  • scripts/water_buoyancy_surface_calc.gd

Open the folder on GitHubat commit 4c4d0ff

Compare with similar skills

Godot Raycasting Queries next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Godot Raycasting Queries compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Godot Raycasting Queries this skillthedivergentai/GD-Agentic-Skills821—~3.3kAutomated safety check: PassLGPL-3.0
Godot Gdscript Patterns925236118/AlphaAgent10310 repos~5kAutomated safety check: PassMIT
2D Map and Scene Generator0x0funky/agent-sprite-forge4.4k—~2.9kAutomated safety check: PassMIT
Godot UI Integrationzimo-xiao-zheng/godot-ui-integration285—~1.5kAutomated safety check: PassMIT
Godot Wechat Minigame Adaptergodothub/godot-minigame187—~1.5kAutomated safety check: PassMIT
AI Game Art Pipelineybuild-ai/ai-game-art-pipeline-skill297—~1.1kAutomated safety check: PassMIT

Similar skills

  • Godot Gdscript Patterns

    925236118/AlphaAgent

    Master Godot 4 GDScript patterns including signals, scenes, state machines, and optimization.

    103 GitHub starsUsed in 10 repos~5k tokens
    Game DevelopmentAuto-check passed
  • 2D Map and Scene Generator

    0x0funky/agent-sprite-forge

    Plans and builds 2D game maps and scenes, from tilemaps and parallax backgrounds to HD-2D plates, with collision checks, a playable HTML preview and Tiled, Godot or LDtk export.

    4.4k GitHub stars~2.9k tokensUpdated 4 days ago
    Game DevelopmentAuto-check passed
  • Godot UI Integration

    zimo-xiao-zheng/godot-ui-integration

    Build or revise Godot UI from an approved design, separated art, or a visual reference when scene structure, gameplay binding, and runtime visual verification all matter.

    285 GitHub stars~1.5k tokensUpdated 1 mo ago
    Game DevelopmentAuto-check passed
  • Godot Wechat Minigame Adapter

    godothub/godot-minigame

    Apply the bundled self-contained Godot WeChat Mini Game adapter kit to an official Godot checkout.

    187 GitHub stars~1.5k tokensUpdated 25 days ago
    Game DevelopmentAuto-check passed
  • AI Game Art Pipeline

    ybuild-ai/ai-game-art-pipeline-skill

    Provider-neutral open-source skill for planning and producing game-runtime art assets and animation: static props/icons, canonical character sheets, combat sprites, 3D/video motion references…

    297 GitHub stars~1.1k tokensUpdated 3 mo ago
    Game DevelopmentAuto-check passed
  • MCP Driver

    RandallLiuXin/GodotMaker

    Runtime debugging and live project inspection via godot-mcp.

    550 GitHub starsUsed in 1 repo~1.1k tokens
    Game DevelopmentAuto-check passed

More from thedivergentai/GD-Agentic-Skills

All 98 skills in this repo
  • Godot 2D Animation

    thedivergentai/GD-Agentic-Skills

    Expert patterns for 2D animation in Godot using AnimatedSprite2D and skeletal cutout rigs.

    821 GitHub stars~3.6k tokensUpdated 1 mo ago
    Auto-check passed
  • Godot 3D World Building

    thedivergentai/GD-Agentic-Skills

    Expert patterns for 3D level design using GridMap with MeshLibrary, CSG constructive solid geometry, occlusion, and runtime GridMap builders.

    821 GitHub stars~3.3k tokensUpdated 1 mo ago
    Auto-check passed
  • Godot Adapt 2D To 3D

    thedivergentai/GD-Agentic-Skills

    Expert patterns for migrating 2D games to 3D including node type conversions, camera systems (third-person, first-person, orbit), physics layer migration, sprite-to-model art pipeline, and control…

    821 GitHub stars~4.7k tokensUpdated 1 mo ago
    Auto-check passed
  • Godot Adapt 3D To 2D

    thedivergentai/GD-Agentic-Skills

    Expert patterns for simplifying 3D games to 2D including dimension reduction strategies, 2.5D fake-depth, isometric ports, camera flattening, physics conversion, 3D-to-sprite art pipeline, and…

    821 GitHub stars~4.5k tokensUpdated 1 mo ago
    Auto-check passed
  • Godot Agent Vision

    thedivergentai/GD-Agentic-Skills

    Agentic eyes for Godot work: cross-platform screenshot CLI (asset/region/window/screen) to budgeted WebP, TEMP editor viewport bridge under .gdskills/, and Taste Receptor Atlas v2 (~237…

    821 GitHub stars~3.5k tokensUpdated 1 mo ago
    Auto-check passed
  • Godot Animation Tree Mastery

    thedivergentai/GD-Agentic-Skills

    Expert patterns for AnimationTree including StateMachine transitions, BlendSpace2D for directional movement, BlendTree for layered animations, root motion, transition conditions, advance…

    821 GitHub stars~3.6k tokensUpdated 1 mo ago
    Auto-check passed

Works with

Questions about Godot Raycasting Queries

What does Godot Raycasting Queries do?

Expert blueprint for physics queries using RayCast, ShapeCast, and DirectSpaceState. Godot Raycasting Queries is an agent skill from thedivergentai/GD-Agentic-Skills. Expert blueprint for physics queries using RayCast, ShapeCast, and DirectSpaceState.

When should I use Godot Raycasting Queries?

Godot Raycasting Queries fits situations like: implementing projectiles; terrain grounding.

How do I install Godot Raycasting Queries in Claude Code?

Run `npx skills add thedivergentai/GD-Agentic-Skills --skill godot-raycasting-queries -a claude-code`. Or copy the skill folder (skills/godot-raycasting-queries in thedivergentai/GD-Agentic-Skills) into .claude/skills/godot-raycasting-queries in your project. Claude Code loads it when a task matches its description.

How do I install Godot Raycasting Queries in Codex?

Run `npx skills add thedivergentai/GD-Agentic-Skills --skill godot-raycasting-queries -a codex`. Or copy the skill folder (skills/godot-raycasting-queries in thedivergentai/GD-Agentic-Skills) into .agents/skills/godot-raycasting-queries in your project. Codex loads it when a task matches its description.

Can I use Godot Raycasting Queries in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add thedivergentai/GD-Agentic-Skills --skill godot-raycasting-queries -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/godot-raycasting-queries, .gemini/skills/godot-raycasting-queries, .github/skills/godot-raycasting-queries and .opencode/skills/godot-raycasting-queries in your project.

What does Godot Raycasting Queries need to run?

SKILL.md names no scripts, command-line tools or credentials: Godot Raycasting Queries is instructions for the agent only.

Does Godot Raycasting Queries access the network?

SKILL.md names 1 domain. As links in the text: docs.godotengine.org. This is read from the text; nothing was executed.

Is Godot Raycasting Queries safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. The check reads SKILL.md only: the scripts in the folder are not scanned, so read them before running anything.

What licence does Godot Raycasting Queries use?

Godot Raycasting Queries is published under the LGPL-3.0 licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Godot Raycasting Queries use?

About 3.3k tokens (SKILL.md is roughly 13k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full. Its references folder adds about 1.5k tokens, read only when the agent opens those files.

What are the alternatives to Godot Raycasting Queries?

Skills that share tags, products or a category with Godot Raycasting Queries: Godot Gdscript Patterns (925236118/AlphaAgent, 103 stars), 2D Map and Scene Generator (0x0funky/agent-sprite-forge, 4.4k stars), Godot UI Integration (zimo-xiao-zheng/godot-ui-integration, 285 stars) and Godot Wechat Minigame Adapter (godothub/godot-minigame, 187 stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Godot Raycasting Queries?

thedivergentai (a GitHub user) maintains it in thedivergentai/GD-Agentic-Skills, which has 821 GitHub stars. The repository holds 98 skills in this directory. The repository was last updated on September 9, 2026.

Source: thedivergentai/GD-Agentic-Skills on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.