/unity-dev:unity-navigationfrom unity-dev
Guides through Unity NavMesh pathfinding: baking walkable surfaces, configuring NavMeshAgent movement, obstacles, links, click-to-move, and patrol routes. Includes a symptom-to-reference table for common issues.
Ships in unity-dev. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
| Symptom | Go to |
|---|---|
| The agent does not move at all | §2 |
| It moves but slides instead of walking / fights the animation | §3 |
| It walks through a wall, or ignores an obstacle | reference/obstacles-links-baking.md §4 |
| It stutters or overshoots at corners | §3 |
| It reaches near the target and stops short | §2 pathPending |
| It cannot cross a gap, stairs, a ledge | reference/obstacles-links-baking.md §5 links |
| Agents avoid an area they should prefer, or vice versa | reference/obstacles-links-baking.md §5 areas and costs |
| NavMesh baking at runtime; a generated or streamed level | reference/obstacles-links-baking.md §6 |
| It will not enter a doorway or cross a narrow ledge | reference/obstacles-links-baking.md §6 — voxel size, before anything else |
| Generate Links produced no links at all | reference/obstacles-links-baking.md §6 — the agent type's Drop Height / Jump Distance |
| Carving obstacles are costing frames | reference/obstacles-links-baking.md §4, then §6 tile size |
| Click-to-move, a patrol route, a chase — a working agent script rather than an explanation; also corner speed, locomotion, runtime bake | reference/recipes.md |
agent.target or NavMesh.Bake() will not compile | reference/agent-api.md |
| Click-to-move in a 2D (XY) top-down game | reference/recipes.md §9 |
Two things own the transform and only one can win. A
NavMeshAgentwritestransform.positionevery frame; so does root motion, and so does any movement script you wrote. Nearly every "the agent slides", "it teleports back", "it fights the animation" report is that conflict, not a baking problem. Decide the owner first — §3.
The split is real and it is the first compile error.
| Types | Namespace | Assembly | Ships with |
|---|---|---|---|
NavMeshAgent, NavMesh, NavMeshObstacle, NavMeshPath | UnityEngine.AI | UnityEngine.AIModule | the engine |
NavMeshSurface, NavMeshLink, NavMeshModifier, NavMeshModifierVolume | Unity.AI.Navigation | Unity.AI.Navigation | com.unity.ai.navigation |
There is no UnityEngine.AI.NavMeshSurface. So an agent compiles in a project with no navigation
package, and the surface that would give it something to walk on does not. Check before writing
against the package: System.Type.GetType("Unity.AI.Navigation.NavMeshSurface, Unity.AI.Navigation")
returns null without it. Installing the package headlessly: unity-new-project →
reference/package-bootstrap.md.
A project that already has navigation has already made these decisions, and adding a second
NavMeshSurface or a second agent type is how you get two disagreeing NavMeshes.
Check, in this order: existing NavMeshSurface components and what each collects; the agent
types defined in Navigation settings; whether anything bakes at runtime. Then ask what you still
do not know — agent radius, height, step height and max slope are properties of the character,
not defaults, and baking with the wrong ones produces a mesh that is subtly too generous.
Two layers steer, and they fail differently. A* over the baked polygons picks the route; RVO local avoidance picks the next step. A wrong route is §5–§6, a crowd that shoves or stalls is §4 — both in
reference/obstacles-links-baking.md.
agent.destination = target.position; // or agent.SetDestination(pos), which returns
// whether the request was accepted
Check the path, not the position.
if (agent.pathStatus == NavMeshPathStatus.PathComplete) { /* reachable */ }
else if (agent.pathStatus == NavMeshPathStatus.PathPartial) { /* only partway */ }
else { /* PathInvalid */ }
PathPartial is the one that masquerades as a bug: the agent walks confidently to a point that
is not the target and stops. It means the destination is off the NavMesh or behind a gap with
no link.
NavMesh.CalculatePathreturnstruefor a partial path. On two deliberately disconnected islands it givesreturned=True status=PathPartial corners=2. Only a target that maps to no NavMesh position at all givesreturned=False status=PathInvalid corners=0. Checking the bool is not checking the path — a great deal of "it walks to the wrong place" code is a correct-lookingif (CalculatePath(...)). All three cases:reference/agent-api.md§1.
remainingDistanceis meaningless while a path is being calculated. Guard it, or arrival fires on frame one because the value is stillInfinity— or never fires because it is zero.
if (!agent.pathPending && agent.remainingDistance < 0.5f) { Arrived(); }
Not moving at all, in order: the agent is not on the NavMesh (agent.isOnNavMesh is false —
it was spawned above or beside it); agent.isStopped is true; the destination is unreachable
(check pathStatus); nothing was baked; or the agent's radius/height exceed the gap it is being
asked to enter, so the mesh has no surface there.
Getting onto the NavMesh: NavMesh.SamplePosition finds the nearest valid point, and
agent.Warp(pos) is how you teleport. Do not assign transform.position to move an agent —
it desyncs from the NavMesh and the agent snaps back or stops responding.
SamplePosition'smaxDistanceis a 3D radius, not a ground-plane one. A query at(0, 50, 0)directly above a baked surface withmaxDistance = 2returns false. An object spawned above the level — dropped in, or at a prefab's authored height — is not "near" the NavMesh: a large share of "the agent will not move". Sample from roughly ground height, or pass amaxDistancethat spans the drop. The sampled point sits slightly above the surface (e.g.y = 0.08on a plane aty = 0), so comparing it to the ground's exact height fails.
agent.isOnNavMeshisfalseoutside play mode. An agent placed directly on a freshly baked surface in the Editor, not playing, reportsisOnNavMesh=Falsewithenabled=True. It is a runtime state — do not use it as a headless diagnostic, or you will conclude the bake is broken when it is not. As withPhysics.Simulate(): the query is real, the context is not.
agent.isStopped = true pauses but keeps the path; agent.ResetPath() discards it. They are
different intentions and using the wrong one is why an agent "resumes" to the wrong place.
Names that do not exist, [Obsolete] members that still compile, Move versus Warp, and the
velocity / desiredVelocity / speed split: reference/agent-api.md
§2.
| Setup | updatePosition | updateRotation | Animation |
|---|---|---|---|
| Agent drives, animation follows (default, simplest) | true | true | Feed agent.velocity.magnitude into the locomotion blend tree |
| Animation drives, agent advises (root motion) | false | true | Read agent.desiredVelocity, drive the Animator, then write agent.nextPosition = transform.position each frame |
The second is what removes foot sliding, and it is also where people get stuck: if you disable
updatePosition and never write back nextPosition, the agent's internal position never
advances and pathing silently stops working while the character keeps animating. Rotation stays
with the agent in both rows — leave updateRotation true unless your own code writes
transform.rotation, or the character stops turning altogether.
Feed the blend tree from agent.velocity (actual, post-avoidance); lean or turn from
agent.desiredVelocity (intended, pre-avoidance). Confusing them animates avoidance the
character is not performing.
Animator and blend-tree construction itself: unity-rigged-character.
Corner stutter and overshoot is steering, not baking: angularSpeed too low for the turn,
acceleration too high, or stoppingDistance at zero so the agent oscillates around the exact
point. Raising stoppingDistance above zero fixes more "jitter at the destination" reports than
anything else — and zero is the default, so this is the common case, not the unusual one.
autoBraking off makes an agent hold its speed through a waypoint — right for a patrol, wrong
for a single destination it is meant to stop at. Every default of a fresh agent, worth
knowing before you "tune" anything: reference/agent-api.md §3.
The scripts themselves live in reference/recipes.md §5: both rows
above, runnable, with the blend tree root motion expects, head look-at, and (§4) a corner speed
limiter.
reference/obstacles-links-baking.md§4 carve or avoid, and why a wall missing from the bake is walked through; §5 NavMeshLink,
areas and costs, modifiers and volumes; §6 BuildNavMesh / UpdateNavMesh, voxel size and the
runtime baker. Same numbering there.
Assertions do not see a bad NavMesh. Look at it: the navigation overlay in the Scene view
shows the baked surface and the carves, and an agent's current path can be drawn from
agent.path.corners. Screenshot-driven verification is unity-debug.
Cheap runtime probes worth keeping while building: log pathStatus on every destination set,
and assert agent.isOnNavMesh on spawn — in play mode only, per §2.
Baking is headless-friendly. NavMeshSurface.BuildNavMesh() over a couple of primitive planes
completes in milliseconds from a batch-mode Editor and produces a live navMeshData, with
NavMesh.SamplePosition and NavMesh.CalculatePath answering correctly against it immediately
afterwards. So bake-and-query is a real automated test you can write, even though agent
movement is not — build the surface from CollectObjects.Children, bake, call
NavMesh.CalculatePath, and assert on path.status, never on the bool. The snippet:
reference/recipes.md §6. Time the bake on your own scene (reference/obstacles-links-baking.md §6).
Driving the Editor to run it: unity-debug → reference/editor-control.md.
Rigs, Avatars and Animator layers (unity-rigged-character), PhysX collision and triggers
(unity-physics-3d), 2D grid pathfinding (unity-2d-grid), and enemy decisions: patrol,
chase, perception, waves (unity-game-ai).
What SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub tipoli5890/game-studio --plugin unity-dev51 skills in this plugin
/unity-2d-animationSkeletal 2D characters: PSB rig, bones and weights, sprite swaps, 2D IK (2D Animation package)./unity-2d-controllerMove a 2D character: platformer jump, slopes, coyote time, moving platforms, top-down movement./unity-2d-gridGrid tactics and tile puzzles, hex or square: move range, A* paths, line of sight, turns, undo./unity-2d-level2D level layout as data: Tiled/LDtk import, rooms, endless chunks, seeded levels, jump reachability.