Pathfinding Failures
Scenario: An NPC enemy refuses to move toward the player in a specific area of the map. In the editor the navmesh looks baked and correct. The enemy works fine in most of the level but consistently gets stuck near the south doorway.
Setup
Enemy:CharacterBody3Dwith aNavigationAgent3DchildNavigationRegion3D: covers the main room and corridors- Enemy script calls
navigation_agent.set_target_position(player.global_position)every second
Step 1: Observe the stuck enemy
Step 2: Check the path
Step 3: Investigate the navmesh
Step 4: Verify the diagnosis
Step 5: Apply the fix
Key takeaways
path_distanceis the fastest way to diagnose navmesh disconnection.reachable: falseimmediately tells you the enemy cannot reach the target — no guessing.- Agent radius × 2 must be less than the narrowest passage. This is the fundamental rule of navmesh baking. Narrow doors, tight corridors, and sharp corners all reduce effective navigable width.
- The navmesh baking happens at design time, not at runtime. Structural changes (wider doorway) require rebaking. Property changes to
NavigationRegion3D(agent_radius) also require rebaking. - Verify with
path_distanceafter the fix, not just by eye. The navmesh may still have gaps that are not visually obvious.
Related patterns
If path_distance returns reachable: true but the enemy still does not move:
spatial_inspect (NavigationAgent3D):
- is_navigation_finished=true → agent thinks it has arrived (check target_desired_distance)
- target_position=[0,0,0] → the script is not calling set_target_position()
- navigation_layers ≠ navmesh layers → layer mismatch (agent and region must match)