NavMesh2D PRO

Performance & technical docs

Performance

How NavMesh2D Pro stays fast with thousands of agents, what every runtime change costs, and how to tune it for your game. Plus the technical reference: threading, requirements and the scripting cheat sheet.

On this page · Benchmark

01 · Benchmark

3,000 agents with avoidance, at 90 FPS.

A stress test with every agent pathfinding and avoiding its neighbours, captured live. Heavy work runs as Burst-compiled jobs spread across all CPU cores, on ordinary MonoBehaviours.

3,000agents with obstacle avoidance
90 FPSsustained frame rate
0 GCallocations per frame in animation
Test machine · Intel i7-9700K, 8 cores @ 3.60 GHzlive capture

02 · Design principles

Built to be fast without rewriting your game.

Burst, no DOTS

Parallel jobs for triangulation, pathfinding, avoidance, clamping, separation and sight. No ECS conversion.

CPU first

Precomputed data is favoured over per-frame work, at the expense of some memory.

Zero GC per frame

No garbage in animation, and carving rebakes are allocation-free after warm-up.

Only what changed

A toggled gate or a re-priced area touches only the affected data, never a full rebuild.

No frame hitches

Expensive rebuilds, like carving, happen in the background.

Shared profiles

Shape and animation profiles are separate, and agents reuse them, so crowds are processed in batches.

Static API

No scene singleton to set up. Create a mesh and an agent and you're ready.

Visible state

Scene gizmos tell you what is happening at any moment.

03 · Measure first

Read the profiler before changing anything.

Add the ENABLE_NAVMESH2D_PROFILER scripting define in Project Settings → Player to get an on-screen overlay with per-phase timings.

Built-in profiler overlay in the Game view
PhaseWhat it measures
PathfindingRoute solving and per-agent steering toward the next waypoint. Steering scales with the whole crowd, so it usually dominates this number.
AvoidanceNeighbour gathering, the optional sight filter and the avoidance solver.
Mesh ClampingKeeping agents on the walkable surface, including closed-gate barriers.
Hard SeparationBroadphase and de-penetration of overlapping agents.
Mesh CarvingThe carving rebake check and the background rebake.

04 · Throttle the solve

Think less often. Keep moving every frame.

Navigation Tick Interval is the single biggest lever. It sets how often agents re-plan, avoid and steer. Movement, rotation and animation still run every rendered frame using the last solved velocity, so motion stays smooth and only reaction time gets slightly coarser.

  • Default is 0: solve every frame.
  • Recommended for most games: 0.05 to 0.1 (10–20 solves per second). The visual difference is negligible and the solve cost drops proportionally.
  • At 120 FPS, solving 20 times a second instead of 120 cuts most of the cost.
  • It also caps every animation profile's Path Refresh Interval.
Parallel pathfinding is on by default and falls back to single-threaded Burst below a small batch size (16 agents), where scheduling would cost more than it saves. Both produce identical routes; leave the defaults unless profiling says otherwise.

05 · Tuning, ranked

Tips for huge crowds, by impact.

High

Raise the tick interval

Solve navigation 10–20 times a second. Movement still updates every frame.

High

Lower avoidance quality

Background crowds do fine on Basic, decorations on Disabled. Keep Extra near the player.

High

Look at fewer neighbours

Lower Max Neighbors (10 → 5–6) and Neighbor Radius (5 → 2–3). Cost grows with neighbours, not population.

High

Don't carve what moves

Use non-carving obstacles for anything moving continuously, and gates for passages that open and close.

Med

Re-plan only when it matters

Raise Path Refresh Interval for characters chasing slow or static targets.

Med

Keep shape profiles few

Each profile is a full extra bake. Most games need one or two sizes.

Med

Profiles, not overrides

A "fast scout" profile beats 200 agents overriding Max Speed. See section 09.

Low

Simpler colliders

Every input vertex is a triangulation point. 20 points where 200 aren't needed bakes ~10× less work.

Low

Sight filter only when needed

When no agent uses it, the job is skipped entirely: zero cost.

Tool

Measure, don't guess

Re-check the profiler after geometry or parameter changes.

06 · What a change costs

Know what triggers a rebuild, and what doesn't.

Not all runtime operations cost the same. From most to least expensive:

Full bake

rebuilds the navmesh

Changing input colliders, a profile's radius or corner smoothing, adding or moving a gate. A carving obstacle crossing its movement threshold triggers this in the background.

Graph rebuild

reconnects the navmeshes

Adding or removing a navmesh or a link at runtime.

Pose refresh

updates the mesh position

Moving a navmesh (translation only).

Cache rebuild

refreshes route data

Opening or closing a gate (passage or sight), blocking a link direction.

Essentially free

single-value writes

Changing an area tag's cost (you could do it every frame), moving a non-carving obstacle, changing any agent property.

Gate or carving obstacle? Gates only re-price the route graph; a carving obstacle rebuilds geometry. Use a gate whenever a passage's shape doesn't need to change.

07 · Avoidance as a budget

Pay for quality only where players look.

Avoidance quality is set per animation profile, and can be changed per agent. Assign the cheapest level each class of agent needs. Mixing levels degrades gracefully: a pair of agents uses the lower of the two.

LevelAddsTypical use
DisabledRaw movement, no avoidance.Decorations
BasicMutual avoidance between agents and obstacles.Background crowds
Improved+ deadlock breaking, congestion braking.Most characters
Extra+ a smarter split of who yields how much.Near the player, dense crowds
  • Per-agent quality is free: setting agent.AvoidanceQuality does not copy the profile, so the agent stays in its batch.
  • The neighbour buffer is sized by the largest Max Neighbors in play: one profile at 50 inflates memory for the whole batch.
  • Avoided By Others = off makes an agent invisible to other solvers: ghosts, projectiles, the player.
  • Avoidance presets switch tuning (indoor vs outdoor) for the whole scene with one call.

08 · Profiles vs overrides

Batches are fast. Singletons are not.

Agents are grouped by animation profile and processed in batches. Writing a setting on an agent (for example agent.MaxSpeed) gives it a private copy and its own group. 500 agents each overriding a value means 500 groups instead of one.

  • Define profiles at edit time for each variant: "fast scout" and "slow tank".
  • Batch runtime changes: setting two properties in the same frame copies the profile once.
  • Overrides last for the agent's lifetime. Check agent.IsAnimationProfileOverriden.

09 · Two sight rule sets

Pick the right one: it's about correctness and speed.

Walls block · CheckVisibility

Portal walk scoped to one navmesh; its outer edge is a wall. Cost is proportional to the portals between viewer and target, very cheap within one area. Used internally by the crowd sight filter.

Only obstacles block · …InOpenSpace

Scans obstacle edges across every mesh the query touches, broadphased by bounding boxes. Cost scales with occluders in the region, not mesh complexity.

  • Both trace a profile-agnostic sight mesh: vision never depends on the looker's size.
  • Gates with sight blocking occlude both rule sets, for every character size.
  • Point-to-point open-space checks and sight raycasts are thread-safe.

10 · Threading & API

Call it from your own jobs.

The API was designed so most functions are thread-safe: call them from your own jobs or worker threads. It is a static API with no scene singleton, and navigation never fights your Rigidbody2D because agent position is decoupled from the Transform.

Thread-safe queries

Sampling, raycasts, open-space visibility, random positions, and directional queries with the sight weight at 0.

Safe background reads

Rebakes publish new data while running queries keep reading the old one, until they finish.

One tick for all

Agents have no Update(). Each navmesh ticks all its agents together, which is what makes crowds cheap.

11 · Editor-only costs

Don't measure with the overlays on.

  • Show Agent Paths and Show Agent Corridors force pathfinding through a synchronous main-thread solve so they can draw the full route. Orders of magnitude slower than the Burst job. Never measure with either on.
  • Auto-rebake on edit rebakes on every change. Disable it on complex meshes while placing colliders, then bake manually. Raise the Editor Rebake Cooldown if the editor stutters.
  • While dragging handles, rebakes run in memory and saving waits until the drag ends.
  • Hundreds of links each draw a clickable gizmo. Select only what you're inspecting.

12 · Scripting cheat sheet

The calls you'll use most.

SiliconHeart.Navigation
// ---- Agent ---------------------------------------------------------
agent.SetDestination(worldPosition);
agent.ClearDestination();
agent.SetPosition(worldPosition);         // teleport (never assign transform.position)
agent.SetHeadingDirection(direction);
agent.DestinationReached += a => { };
agent.PathFound += (a, waypoints) => { };
agent.HasDestination; agent.IsPathPartial; agent.RemainingPathLength;
agent.CurrentVelocity;                    // feed your Animator with this
agent.MaxSpeed = 6.0f;                    // writing a setting switches to a private copy

// ---- Navmesh instance ----------------------------------------------
navMesh.GenerateFromScene();
navMesh.BlockGate(gateIndex, blockAtoB, blockBtoA);
navMesh.BlockGateSight(gateIndex, blockSight);
navMesh.FindNearestGate(worldPosition, maxDistance);
navMesh.CheckVisibility(eye, range, targetAgent);          // walls block
navMesh.GetAgentsInRadius(pos, radius, results, true);

// ---- World queries (static) ----------------------------------------
NavMesh2D.SamplePosition(shapeProfile, point, maxDistance, out result);
NavMesh2D.FindRandomReachablePosition(shapeProfile, origin, radius, out result);
NavMesh2D.SampleRandomPosition(shapeProfile, origin, maxDistance, out result, requireLineOfSight);
NavMesh2D.FindContainingNavMesh(worldPosition, shapeProfile);
NavMesh2D.Raycast(shapeProfile, origin, direction, maxDistance, out hit);
NavMesh2D.RaycastSightInOpenSpace(origin, direction, maxDistance, out hit);
NavMesh2D.CheckVisibilityInOpenSpace(eye, targetPoint);      // only obstacles block
NavMesh2D.GetVisibleAgentsInOpenSpace(eye, range, results);
NavMesh2D.FindDirectionalDestinations(shapeProfile, from, reference, in parameters, candidates);

// ---- Obstacle / Link -----------------------------------------------
obstacle.Carving = true;
obstacle.BlocksLineOfSight = false;
link.BlocksAtoB = true;
link.Cost = 5.0f; link.OverrideCost = true;

// ---- Global settings -----------------------------------------------
NavMesh2DSettings.Instance.SetActiveAvoidanceProfile("Crowded market");