Godot ai navigation

From thedivergentai/GD-Agentic-Skills · View interactive version

Godot ai navigation is an AI agent skill from the GitHub repository thedivergentai/GD-Agentic-Skills. 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

How to use this skill

Skill file

Decision Trees (MANDATORY script triggers)

1. Node agent vs NavigationServer RID

| Signal | Choice | Pathfinding script (MANDATORY read) |

| :--- | :--- | :--- |

| 2D top-down / side-scroller, < ~50 agents, editor-tweakable | NavigationAgent2D on CharacterBody2D | smart_navigation_agent.gd |

| 3D floor/slope nav, < ~50 agents, designer-placed regions | NavigationAgent3D on CharacterBody3D | Same script (3D branch); pair with godot-physics-3d for body collision |

| Hundreds–thousands of simple movers (2D or 3D) | RID agents on NavigationServer | server_navigation_setup.gd + low_level_avoidance.gd |

| Agents stuck / jittering | Stuck recovery before retarget spam | agent_stuck_detection.gd |

2. Bake vs obstacle

| Signal | Choice | Pathfinding script (MANDATORY read) |

| :--- | :--- | :--- |

| Walkable geometry changed (proc gen, doors) | Async parse + bake | async_dynamic_baking.gd |

| Moving platform / shifting region | Dynamic region manager | dynamic_nav_manager.gd |

| Projectile / rolling hazard pushing agents | RVO obstacle (no full rebake) | moving_obstacle_server.gd |

| Prefer roads over mud/water | Region enter/travel costs | terrain_cost_manager.gd |

3. Layers, links, crowds

| Signal | Choice | Pathfinding script (MANDATORY read) |

| :--- | :--- | :--- |

| Walk / fly / swim (or faction) filters | Navigation layers bitmasks | layer_mask_navigation.gd |

| Jump / teleport / elevator edges | NavigationLink traversal | nav_link_traversal.gd |

| Formation / anti-clump crowds | Leader-relative offsets | group_avoidance_formations.gd |

| Hot-path query allocs | Reuse query parameter/result objects | memory_optimized_queries.gd |

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)

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

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:

  1. Defer first target_position with call_deferred + await get_tree().physics_frame.
  2. Retarget on timer (~0.2s) or distance threshold — never every frame.
  3. On stall: if !nav_agent.is_target_reachable() or velocity ≈ 0 for N frames, skip waypoint or call get_next_path_position() recovery.
  4. Avoidance: set radius > 0 when avoidance_enabled.
  5. Re-install godot-navigation-pathfinding before shipping async bake or RID crowds.

Expert insights (WHY — keep in body)

Golden Path

  1. Classify the AI need with the decision trees above.
  2. MANDATORY open each linked pathfinding script for the chosen rows — Do NOT Load the rest of that skill's scripts.
  3. Wire retarget/state policy here (timer/threshold + state machine), movement via CharacterBody.
  4. 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

Related Skills

Prerequisites
Complements
Downstream / consumers
Master
Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.