Decision Trees (MANDATORY script triggers)
1. Node agent vs NavigationServer RID
2. Bake vs obstacle
3. Layers, links, crowds
Do NOT Load scripts outside the chosen row (e.g. skip RID/server scripts for a single designer-tuned agent; skip async bake when only RVO obstacles move).
4. Chase / patrol retarget policy (AI layer)
- Chase: Retarget on timer (~0.2s) or distance threshold — never assign
target_position every physics frame.
- Patrol: Advance waypoint only when
is_navigation_finished() and is_target_reachable(); on unreachable, pick next or repath.
- State ownership: Patrol/chase/search transitions belong in godot-state-machine-advanced; this skill only decides how to retarget once a state asks for a destination.
Patrol state handoff (call site): in the patrol state's _physics_process, when the agent finishes a waypoint, call retarget_if_needed(next_waypoint) — do not set target_position directly from the state machine root.
# PatrolState.gd — state machine owns transitions; this skill owns retarget policy
func _physics_process(_delta: float) -> void:
if nav_agent.is_navigation_finished() and nav_agent.is_target_reachable():
_ai_nav.retarget_if_needed(_waypoints[_index])
_index = (_index + 1) % _waypoints.size()
# Threshold retarget — AI policy, not per-frame path spam
const RETARGET_DIST := 1.5
var _last_target: Vector3
func retarget_if_needed(desired: Vector3) -> void:
if desired.distance_to(_last_target) < RETARGET_DIST:
return
nav_agent.target_position = desired
_last_target = desired
NEVER Do in AI Navigation
- NEVER set
target_position before awaiting physics frame — MUST call_deferred() then await get_tree().physics_frame.
- NEVER use synchronous runtime bake — Use
bake_from_source_geometry_data_async via pathfinding async_dynamic_baking.gd.
- NEVER poll chase targets every frame — Path recalculation spam.
- NEVER invent local duplicate nav scripts here — Implement from godot-navigation-pathfinding only.
- NEVER ignore
is_target_reachable() / stuck recovery — Unreachable or stalled agents need policy (agent_stuck_detection.gd).
- NEVER leave avoidance radius at 0 when
avoidance_enabled — Agents pass through each other.
- NEVER call
get_path() every frame — Reuse path query objects (memory_optimized_queries.gd).
Fallback (godot-navigation-pathfinding not installed)
If the sibling skill is unavailable, use this minimal stuck-recovery checklist — do not paste full bake/RID tutorials from memory:
- Defer first
target_position with call_deferred + await get_tree().physics_frame.
- Retarget on timer (~0.2s) or distance threshold — never every frame.
- On stall: if
!nav_agent.is_target_reachable() or velocity ≈ 0 for N frames, skip waypoint or call get_next_path_position() recovery.
- Avoidance: set
radius > 0 when avoidance_enabled.
- Re-install godot-navigation-pathfinding before shipping async bake or RID crowds.
Expert insights (WHY — keep in body)
- Deferred first target — WHY: NavigationAgent maps/regions are not ready in
_ready(). call_deferred + await physics_frame prevents first-path failure.
- Retarget policy — WHY: per-frame
target_position rebakes paths and spikes CPU. Timer (~0.2 s) or distance threshold only.
- Unreachable waypoints — WHY: patrol loops stall forever without
is_target_reachable() + skip/repath policy.
- Avoidance radius 0 — WHY: enabled avoidance with zero radius disables separation; agents stack.
Golden Path
- Classify the AI need with the decision trees above.
- MANDATORY open each linked pathfinding script for the chosen rows — Do NOT Load the rest of that skill's scripts.
- Wire retarget/state policy here (timer/threshold + state machine), movement via CharacterBody.
- Do NOT Load Official Docs intro recipes unless first-time region bake UI is required (use Reference links).
Deep recipes (on demand)
| Topic |
Reference / script |
| Chase / patrol / crowd AI recipes |
ai-movement-recipes.md |
Reference
Progressive disclosure: open Official Documentation links only when researching a specific API; load Related Skills when routing to a peer domain — do not preload the whole lattice.
Official Documentation
- Navigation overview — Tutorial index for maps, regions, agents, meshes, links, obstacles, and performance before diving into class pages.
- Navigation introduction (2D) — Minimal NavigationRegion2D + NavigationAgent2D setup, baking walkable polygons, and first-frame readiness.
- Navigation introduction (3D) — Parallel 3D bootstrap with NavigationRegion3D / NavigationAgent3D and mesh baking expectations.
- Using NavigationAgents — target_position, get_next_path_position, avoidance radius, and velocity_computed safe-velocity flow for chase/patrol AI.
- Using NavigationServers — RID maps/regions/agents for node-less crowds and custom server setups at scale.
- Using navigation meshes — Parse/bake source geometry, async baking, and projected obstructions for dynamic carving.
- Using NavigationRegions — Region ownership, enter/travel costs, and chunked/runtime region updates for terrain penalties.
- Using NavigationObstacles — RVO push obstacles vs bake-time carving without full remesh every frame.
- Using NavigationLinks — Jump/teleport/elevator edges and manual link traversal on agents.
- Using navigation layers — 32-bit layer bitmasks for walk/fly/swim (or faction) path filters.
- Using navigation path query objects — Reuse NavigationPathQueryParameters/Result to avoid per-frame GC in crowds.
- Optimizing navigation performance — Bake cost, agent/obstacle counts, and server query budgets for large AI populations.
Related Skills
Prerequisites
- godot-navigation-pathfinding — MANDATORY authoritative NavigationServer scripts (async bake, RID setup, query reuse, stuck detection); this skill has no local
scripts/.
- godot-characterbody-2d — Path corners become CharacterBody velocity via move_and_slide; agent scripts assume a body parent.
- godot-2d-physics — Collision layers/shapes still block bodies; navmesh is not a physics substitute for walls and triggers.
- godot-physics-3d — 3D agents share the same split: NavigationServer paths vs RigidBody/CharacterBody collision and slopes.
Complements
Downstream / consumers
- godot-genre-rts — Unit move commands and RVO crowds consume NavigationAgent/Server patterns directly.
- godot-genre-tower-defense — Lane/path enemies and dynamic blockers depend on regions, costs, and obstacle updates.
- godot-genre-stealth — Guard patrols and investigate points are NavigationAgent routes gated by detection state.
- godot-combat-system — Engage/kite/flank movement issues new targets and stuck recovery on top of paths.
- godot-monte-carlo-balancer — Simulate chase reachability, travel-time bands, and crowd pressure when tuning AI difficulty.
Master
- godot-master — Library router and mirrored module entry for this Domain Skill.
1---2name: godot-ai-navigation3description: AI movement decision router for chase, patrol, crowd, and bake choices on top of NavigationAgent/Server. Use when deciding node agent vs RID server, bake vs obstacle, layer masks, or retarget policy — not for engine navmesh recipes. Keywords: AI navigation, chase retarget, patrol, crowd RVO, bake vs obstacle, NavigationAgent decision tree.4---5
6## Decision Trees (MANDATORY script triggers)
7
8### 1. Node agent vs NavigationServer RID
9| Signal | Choice | Pathfinding script (MANDATORY read) |
10| :--- | :--- | :--- |
11| 2D top-down / side-scroller, < ~50 agents, editor-tweakable | `NavigationAgent2D` on CharacterBody2D | [smart_navigation_agent.gd](https://github.com/thedivergentai/gd-agentic-skills/blob/main/skills/godot-navigation-pathfinding/scripts/smart_navigation_agent.gd) |
12| 3D floor/slope nav, < ~50 agents, designer-placed regions | `NavigationAgent3D` on CharacterBody3D | Same script (3D branch); pair with [godot-physics-3d](https://github.com/thedivergentai/gd-agentic-skills/blob/main/skills/godot-physics-3d/SKILL.md) for body collision |
13| Hundreds–thousands of simple movers (2D or 3D) | RID agents on NavigationServer | [server_navigation_setup.gd](https://github.com/thedivergentai/gd-agentic-skills/blob/main/skills/godot-navigation-pathfinding/scripts/server_navigation_setup.gd) + [low_level_avoidance.gd](https://github.com/thedivergentai/gd-agentic-skills/blob/main/skills/godot-navigation-pathfinding/scripts/low_level_avoidance.gd) |
14| Agents stuck / jittering | Stuck recovery before retarget spam | [agent_stuck_detection.gd](https://github.com/thedivergentai/gd-agentic-skills/blob/main/skills/godot-navigation-pathfinding/scripts/agent_stuck_detection.gd) |
15
16### 2. Bake vs obstacle
17| Signal | Choice | Pathfinding script (MANDATORY read) |
18| :--- | :--- | :--- |
19| Walkable geometry changed (proc gen, doors) | Async parse + bake | [async_dynamic_baking.gd](https://github.com/thedivergentai/gd-agentic-skills/blob/main/skills/godot-navigation-pathfinding/scripts/async_dynamic_baking.gd) |
20| Moving platform / shifting region | Dynamic region manager | [dynamic_nav_manager.gd](https://github.com/thedivergentai/gd-agentic-skills/blob/main/skills/godot-navigation-pathfinding/scripts/dynamic_nav_manager.gd) |
21| Projectile / rolling hazard pushing agents | RVO obstacle (no full rebake) | [moving_obstacle_server.gd](https://github.com/thedivergentai/gd-agentic-skills/blob/main/skills/godot-navigation-pathfinding/scripts/moving_obstacle_server.gd) |
22| Prefer roads over mud/water | Region enter/travel costs | [terrain_cost_manager.gd](https://github.com/thedivergentai/gd-agentic-skills/blob/main/skills/godot-navigation-pathfinding/scripts/terrain_cost_manager.gd) |
23
24### 3. Layers, links, crowds
25| Signal | Choice | Pathfinding script (MANDATORY read) |
26| :--- | :--- | :--- |
27| Walk / fly / swim (or faction) filters | Navigation layers bitmasks | [layer_mask_navigation.gd](https://github.com/thedivergentai/gd-agentic-skills/blob/main/skills/godot-navigation-pathfinding/scripts/layer_mask_navigation.gd) |
28| Jump / teleport / elevator edges | NavigationLink traversal | [nav_link_traversal.gd](https://github.com/thedivergentai/gd-agentic-skills/blob/main/skills/godot-navigation-pathfinding/scripts/nav_link_traversal.gd) |
29| Formation / anti-clump crowds | Leader-relative offsets | [group_avoidance_formations.gd](https://github.com/thedivergentai/gd-agentic-skills/blob/main/skills/godot-navigation-pathfinding/scripts/group_avoidance_formations.gd) |
30| Hot-path query allocs | Reuse query parameter/result objects | [memory_optimized_queries.gd](https://github.com/thedivergentai/gd-agentic-skills/blob/main/skills/godot-navigation-pathfinding/scripts/memory_optimized_queries.gd) |
31
32**Do NOT Load** scripts outside the chosen row (e.g. skip RID/server scripts for a single designer-tuned agent; skip async bake when only RVO obstacles move).
33
34### 4. Chase / patrol retarget policy (AI layer)
35- **Chase**: Retarget on timer (~0.2s) or distance threshold — **never** assign `target_position` every physics frame.
36- **Patrol**: Advance waypoint only when `is_navigation_finished()` **and** `is_target_reachable()`; on unreachable, pick next or repath.
37- **State ownership**: Patrol/chase/search transitions belong in [godot-state-machine-advanced](https://github.com/thedivergentai/gd-agentic-skills/blob/main/skills/godot-state-machine-advanced/SKILL.md); this skill only decides *how* to retarget once a state asks for a destination.
38
39**Patrol state handoff (call site):** in the patrol state's `_physics_process`, when the agent finishes a waypoint, call `retarget_if_needed(next_waypoint)` — do not set `target_position` directly from the state machine root.
40
41```gdscript
42# PatrolState.gd — state machine owns transitions; this skill owns retarget policy
43func _physics_process(_delta: float) -> void:
44 if nav_agent.is_navigation_finished() and nav_agent.is_target_reachable():
45 _ai_nav.retarget_if_needed(_waypoints[_index])
46 _index = (_index + 1) % _waypoints.size()
47```
48
49```gdscript
50# Threshold retarget — AI policy, not per-frame path spam
51const RETARGET_DIST := 1.5
52var _last_target: Vector3
53
54func retarget_if_needed(desired: Vector3) -> void:
55 if desired.distance_to(_last_target) < RETARGET_DIST:
56 return
57 nav_agent.target_position = desired
58 _last_target = desired
59```
60
61## NEVER Do in AI Navigation
62
63- **NEVER set `target_position` before awaiting physics frame** — MUST `call_deferred()` then `await get_tree().physics_frame`.
64- **NEVER use synchronous runtime bake** — Use `bake_from_source_geometry_data_async` via pathfinding [async_dynamic_baking.gd](https://github.com/thedivergentai/gd-agentic-skills/blob/main/skills/godot-navigation-pathfinding/scripts/async_dynamic_baking.gd).
65- **NEVER poll chase targets every frame** — Path recalculation spam.
66- **NEVER invent local duplicate nav scripts here** — Implement from godot-navigation-pathfinding only.
67- **NEVER ignore `is_target_reachable()` / stuck recovery** — Unreachable or stalled agents need policy ([agent_stuck_detection.gd](https://github.com/thedivergentai/gd-agentic-skills/blob/main/skills/godot-navigation-pathfinding/scripts/agent_stuck_detection.gd)).
68- **NEVER leave avoidance radius at 0** when `avoidance_enabled` — Agents pass through each other.
69- **NEVER call `get_path()` every frame** — Reuse path query objects ([memory_optimized_queries.gd](https://github.com/thedivergentai/gd-agentic-skills/blob/main/skills/godot-navigation-pathfinding/scripts/memory_optimized_queries.gd)).
70
71## Fallback (godot-navigation-pathfinding not installed)
72
73If the sibling skill is unavailable, use this minimal stuck-recovery checklist — **do not** paste full bake/RID tutorials from memory:
74
751. Defer first `target_position` with `call_deferred` + `await get_tree().physics_frame`.
762. Retarget on timer (~0.2s) or distance threshold — never every frame.
773. On stall: if `!nav_agent.is_target_reachable()` or velocity ≈ 0 for N frames, skip waypoint or call `get_next_path_position()` recovery.
784. Avoidance: set `radius > 0` when `avoidance_enabled`.
795. Re-install [godot-navigation-pathfinding](https://github.com/thedivergentai/gd-agentic-skills/blob/main/skills/godot-navigation-pathfinding/SKILL.md) before shipping async bake or RID crowds.
80
81## Expert insights (WHY — keep in body)
82
83- **Deferred first target** — WHY: NavigationAgent maps/regions are not ready in `_ready()`. `call_deferred` + `await physics_frame` prevents first-path failure.
84- **Retarget policy** — WHY: per-frame `target_position` rebakes paths and spikes CPU. Timer (~0.2 s) or distance threshold only.
85- **Unreachable waypoints** — WHY: patrol loops stall forever without `is_target_reachable()` + skip/repath policy.
86- **Avoidance radius 0** — WHY: enabled avoidance with zero radius disables separation; agents stack.
87
88## Golden Path
89
901. Classify the AI need with the decision trees above.
912. **MANDATORY** open each linked pathfinding script for the chosen rows — **Do NOT Load** the rest of that skill's scripts.
923. Wire retarget/state policy here (timer/threshold + state machine), movement via CharacterBody.
934. **Do NOT Load** Official Docs intro recipes unless first-time region bake UI is required (use Reference links).
94
95## Deep recipes (on demand)
96
97| Topic | Reference / script |
98|-------|-------------------|
99| Chase / patrol / crowd AI recipes | [ai-movement-recipes.md](references/ai-movement-recipes.md) |
100## Reference
101
102> Progressive disclosure: open Official Documentation links only when researching a specific API; load Related Skills when routing to a peer domain — do not preload the whole lattice.
103
104### Official Documentation
105- [Navigation overview](https://docs.godotengine.org/en/stable/tutorials/navigation/index.html) — Tutorial index for maps, regions, agents, meshes, links, obstacles, and performance before diving into class pages.
106- [Navigation introduction (2D)](https://docs.godotengine.org/en/stable/tutorials/navigation/navigation_introduction_2d.html) — Minimal NavigationRegion2D + NavigationAgent2D setup, baking walkable polygons, and first-frame readiness.
107- [Navigation introduction (3D)](https://docs.godotengine.org/en/stable/tutorials/navigation/navigation_introduction_3d.html) — Parallel 3D bootstrap with NavigationRegion3D / NavigationAgent3D and mesh baking expectations.
108- [Using NavigationAgents](https://docs.godotengine.org/en/stable/tutorials/navigation/navigation_using_navigationagents.html) — target_position, get_next_path_position, avoidance radius, and velocity_computed safe-velocity flow for chase/patrol AI.
109- [Using NavigationServers](https://docs.godotengine.org/en/stable/tutorials/navigation/navigation_using_navigationservers.html) — RID maps/regions/agents for node-less crowds and custom server setups at scale.
110- [Using navigation meshes](https://docs.godotengine.org/en/stable/tutorials/navigation/navigation_using_navigationmeshes.html) — Parse/bake source geometry, async baking, and projected obstructions for dynamic carving.
111- [Using NavigationRegions](https://docs.godotengine.org/en/stable/tutorials/navigation/navigation_using_navigationregions.html) — Region ownership, enter/travel costs, and chunked/runtime region updates for terrain penalties.
112- [Using NavigationObstacles](https://docs.godotengine.org/en/stable/tutorials/navigation/navigation_using_navigationobstacles.html) — RVO push obstacles vs bake-time carving without full remesh every frame.
113- [Using NavigationLinks](https://docs.godotengine.org/en/stable/tutorials/navigation/navigation_using_navigationlinks.html) — Jump/teleport/elevator edges and manual link traversal on agents.
114- [Using navigation layers](https://docs.godotengine.org/en/stable/tutorials/navigation/navigation_using_navigationlayers.html) — 32-bit layer bitmasks for walk/fly/swim (or faction) path filters.
115- [Using navigation path query objects](https://docs.godotengine.org/en/stable/tutorials/navigation/navigation_using_navigationpathqueryobjects.html) — Reuse NavigationPathQueryParameters/Result to avoid per-frame GC in crowds.
116- [Optimizing navigation performance](https://docs.godotengine.org/en/stable/tutorials/navigation/navigation_optimizing_performance.html) — Bake cost, agent/obstacle counts, and server query budgets for large AI populations.
117
118### Related Skills
119
120#### Prerequisites
121- [godot-navigation-pathfinding](https://github.com/thedivergentai/gd-agentic-skills/blob/main/skills/godot-navigation-pathfinding/SKILL.md) — **MANDATORY** authoritative NavigationServer scripts (async bake, RID setup, query reuse, stuck detection); this skill has no local `scripts/`.
122- [godot-characterbody-2d](https://github.com/thedivergentai/gd-agentic-skills/blob/main/skills/godot-characterbody-2d/SKILL.md) — Path corners become CharacterBody velocity via move_and_slide; agent scripts assume a body parent.
123- [godot-2d-physics](https://github.com/thedivergentai/gd-agentic-skills/blob/main/skills/godot-2d-physics/SKILL.md) — Collision layers/shapes still block bodies; navmesh is not a physics substitute for walls and triggers.
124- [godot-physics-3d](https://github.com/thedivergentai/gd-agentic-skills/blob/main/skills/godot-physics-3d/SKILL.md) — 3D agents share the same split: NavigationServer paths vs RigidBody/CharacterBody collision and slopes.
125
126#### Complements
127- [godot-raycasting-queries](https://github.com/thedivergentai/gd-agentic-skills/blob/main/skills/godot-raycasting-queries/SKILL.md) — Line-of-sight, aim cones, and hit prediction sit beside pathfinding for chase/stealth AI.
128- [godot-state-machine-advanced](https://github.com/thedivergentai/gd-agentic-skills/blob/main/skills/godot-state-machine-advanced/SKILL.md) — Patrol/chase/search states own when to retarget NavigationAgent and when to stop.
129- [godot-tilemap-mastery](https://github.com/thedivergentai/gd-agentic-skills/blob/main/skills/godot-tilemap-mastery/SKILL.md) — TileMap/TileSet geometry often feeds NavigationPolygon baking in 2D levels.
130- [godot-3d-world-building](https://github.com/thedivergentai/gd-agentic-skills/blob/main/skills/godot-3d-world-building/SKILL.md) — Static meshes and GridMaps are the usual NavigationMesh source geometry for baked regions.
131- [godot-procedural-generation](https://github.com/thedivergentai/gd-agentic-skills/blob/main/skills/godot-procedural-generation/SKILL.md) — Runtime layouts require parse + bake_from_source_geometry_data_async after generation.
132- [godot-signal-architecture](https://github.com/thedivergentai/gd-agentic-skills/blob/main/skills/godot-signal-architecture/SKILL.md) — velocity_computed / navigation_finished wiring stays clean when AI systems emit typed signals instead of polling.
133
134#### Downstream / consumers
135- [godot-genre-rts](https://github.com/thedivergentai/gd-agentic-skills/blob/main/skills/godot-genre-rts/SKILL.md) — Unit move commands and RVO crowds consume NavigationAgent/Server patterns directly.
136- [godot-genre-tower-defense](https://github.com/thedivergentai/gd-agentic-skills/blob/main/skills/godot-genre-tower-defense/SKILL.md) — Lane/path enemies and dynamic blockers depend on regions, costs, and obstacle updates.
137- [godot-genre-stealth](https://github.com/thedivergentai/gd-agentic-skills/blob/main/skills/godot-genre-stealth/SKILL.md) — Guard patrols and investigate points are NavigationAgent routes gated by detection state.
138- [godot-combat-system](https://github.com/thedivergentai/gd-agentic-skills/blob/main/skills/godot-combat-system/SKILL.md) — Engage/kite/flank movement issues new targets and stuck recovery on top of paths.
139- [godot-monte-carlo-balancer](https://github.com/thedivergentai/gd-agentic-skills/blob/main/skills/godot-monte-carlo-balancer/SKILL.md) — Simulate chase reachability, travel-time bands, and crowd pressure when tuning AI difficulty.
140
141#### Master
142- [godot-master](https://github.com/thedivergentai/gd-agentic-skills/blob/main/skills/godot-master/SKILL.md) — Library router and mirrored module entry for this Domain Skill.