๐Ÿ‘‹ BurstNav Free โ€” ECS Pathfinding for Unity DOTS

BurstNav Free is a zero-allocation navigation package for Unity DOTS: a baked polygon graph feeds a flat A* search, the search fills a per-agent waypoint buffer, and a kinematic funnel turns that corridor into a smooth desired velocity. Every stage is a Burst-compiled job reading chunk arrays โ€” no NavMeshAgent, no MonoBehaviours, no per-frame allocations.

๐Ÿ’ก Why not NavMeshAgent?
NavMeshAgent is an object-oriented wrapper around a managed navigation world. One agent per MonoBehaviour means one transform sync, one callback and one managed object per unit. BurstNav keeps the whole agent state in six ECS components and resolves paths and velocity inside Burst jobs, so hundreds of agents cost chunk iteration instead of main-thread calls.


โœจ Core Features


๐Ÿงญ How the pipeline fits together

BnBlobMeshGraph (singleton)
  -> BnMeshGraphBlob (blob asset)
  -> BnAStar.FindPath + BnPathScratchpad
  -> BnAgentPath + BnPathWaypoint buffer
  -> BnFunnel.Solve
  -> BnAgentSteering.DesiredVelocity
  -> KinematicBypassJob
  -> BnAgentSteering.Velocity
  -> IntegrateJob
  -> BnAgentSteering.Position

Read How It Works for the data passing through each arrow, or jump to Quick Start to get one agent moving.


๐Ÿ“ฆ Package Facts

PropertyValue
Package namesniveler-code.dev.burstnav-ecs
Display nameBurstNav Free
Version1.1.0
Minimum Unity2022.3
Runtime assemblySnivelerCode.BurstNav.Runtime (root namespace BurstNav)
Dependenciescom.unity.entities 1.2.4, com.unity.burst 1.8.12, com.unity.collections 2.4.0, com.unity.mathematics 1.3.1
Verified hostUnity 6000.5.2f1 with com.unity.entities 6.5.0
LicenseMIT
Editor toolingNone โ€” no windows, no define symbols, no project settings

๐Ÿš€ What ships in the box

LayerImplementationMain types
Navigation graphStatic polygon graph in a blob assetBnMeshGraphBlob, BnPolygon, BnLinkData
Graph ownerSingleton component pointing at the blobBnBlobMeshGraph
SearchFlat A* with a fixed iteration budgetBnAStar, BnPathScratchpad, BnLinkFilter
Path storagePer-agent path slot and waypoint bufferBnAgentPath, BnPathWaypoint
SteeringKinematic funnel over portal edgesBnFunnel
VelocityKinematic bypass: desired velocity becomes velocityKinematicBypassJob
IntegrationPosition advanced by velocity and delta timeIntegrateJob
EnvironmentStatic navmesh onlyBnMeshAuthoring
Agent authoringOne dominant agent archetypeBnAgentAuthoring, BnAgentSteering

Two samples are included: Hello Navmesh (one agent patrolling a 4 ร— 4 grid) and Funnel Steering (four agents crossing a 6 ร— 6 grid on diagonals). Both are imported from the Package Manager Samples tab.


โš ๏ธ What Free deliberately does not do

Free is a single-agent-quality steering pipeline. It has no local avoidance, no dynamic obstacles and no door/area tags โ€” those stages do not exist in the runtime, so there is nothing to tune or toggle. If a level needs crowds that separate, obstacles that move, or doors that close, read Limitations & Scope before you commit to the package.


๐Ÿ“š How this documentation is organised

Every type lives in the BurstNav namespace; every code snippet on these pages compiles against SnivelerCode.BurstNav.Runtime.


โš™๏ธ Installation & Requirements

Requirements

BurstNav Free targets the Entities 1.x line. The package declares its DOTS dependencies in package.json, so Unity resolves them for you โ€” but they must be pinnable in your project.

RequirementVersionNotes
Unity Engine2022.3 or newerDeclared as "unity": "2022.3" in package.json.
Unity Entities1.2.4Pulled in automatically. Verified host: Unity 6000.5.2f1 with com.unity.entities 6.5.0.
Burst Compiler1.8.12Pulled in automatically.
Unity Collections2.4.0Pulled in automatically.
Unity Mathematics1.3.1Pulled in automatically.
AI Modulebuilt-inNot used at runtime; only a host project's own NavMesh code would need it.

There is no scripting define, no editor setting and no project configuration step. If the DOTS packages compile, BurstNav compiles.

Install the package

  1. Open Window โ†’ Package Manager.
  2. Click + โ†’ Add package from diskโ€ฆ
  3. Select the package.json inside sniveler-code.dev.burstnav-ecs.
  4. Wait for compilation and confirm the Console has no errors.

The equivalent Packages/manifest.json entry for an embedded or local copy looks like this:

{
  "dependencies": {
    "com.unity.burst": "1.8.12",
    "com.unity.collections": "2.4.0",
    "com.unity.entities": "1.2.4",
    "com.unity.mathematics": "1.3.1",
    "sniveler-code.dev.burstnav-ecs": "file:../sniveler-code.dev.burstnav-ecs"
  }
}

๐Ÿ’ก Keep every .meta file. The GUIDs inside them keep serialized references โ€” authoring components in scenes, subscene references and sample assets โ€” stable across package updates. Deleting .meta files makes Unity re-create them with new GUIDs and every baked reference breaks.

Runtime assembly

PropertyValue
Assembly nameSnivelerCode.BurstNav.Runtime
Root namespaceBurstNav
allowUnsafeCodetrue
autoReferencedtrue
ReferencesUnity DOTS assemblies only (Unity.Entities, Unity.Entities.Hybrid, Unity.Transforms, Unity.Burst, Unity.Collections, Unity.Mathematics, Unity.Jobs)

Because the assembly is auto-referenced, a project with no assembly definitions can use the package immediately. As soon as your gameplay code lives in its own .asmdef, add SnivelerCode.BurstNav.Runtime to that file:

{
  "name": "Game.Navigation",
  "rootNamespace": "Game.Navigation",
  "references": [
    "SnivelerCode.BurstNav.Runtime",
    "Unity.Entities",
    "Unity.Burst",
    "Unity.Collections",
    "Unity.Jobs",
    "Unity.Mathematics"
  ],
  "allowUnsafeCode": false,
  "autoReferenced": true
}

Add Unity.Entities.Hybrid and Unity.Transforms when the same assembly also contains authoring components and bakers โ€” assembly references are not transitive.

โš ๏ธ Do not rename the runtime assembly. Unity resolves assembly references by name; a renamed SnivelerCode.BurstNav.Runtime.asmdef breaks every snippet in this documentation.

Import the samples

  1. Window โ†’ Package Manager.
  2. Select BurstNav Free.
  3. Open the Samples tab.
  4. Import Hello Navmesh or Funnel Steering.

Unity copies the sample into Assets/Samples/BurstNav Free/1.1.0/, leaving the package copy under Samples~ untouched. Each sample folder contains one scene, a Scripts folder with its own assembly definition, and a README.

If you previously imported samples from an older package version, delete Assets/Samples/BurstNav Free before importing again: Unity matches copied assets by path and GUID, so a stale copy silently shadows the new one.

Neither sample needs a SubScene bake โ€” a bootstrap MonoBehaviour builds the graph blob from the Free data types and spawns the agents when Play starts.

Verify the installation

CheckExpected
ConsoleNo compile errors, no Burst warnings about SnivelerCode.BurstNav.Runtime.
Jobs โ†’ Burst โ†’ Enable CompilationOn (default).
SystemsAfter a scene with a BnBlobMeshGraph runs, BnPathfindingSystem and BnSteeringSystem appear in Window โ†’ Entities โ†’ Systems.
Menu barThere is no BurstNav/โ€ฆ menu โ€” the package ships no editor tooling.

Running the tests

The package contains SnivelerCode.BurstNav.Tests.EditMode and SnivelerCode.BurstNav.Tests.PlayMode. Like any package test set, they compile only when the package is listed under testables in Packages/manifest.json:

{
  "testables": ["sniveler-code.dev.burstnav-ecs"]
}

Then open Window โ†’ General โ†’ Test Runner and run either assembly.

Next step

Continue with Quick Start to bake a graph and move an agent, or read How It Works first if you want the architecture before the code.


๐Ÿš€ Quick Start

This page takes an empty project to one agent that follows a path across a baked 4 ร— 4 navigation grid. Every type and call below is part of the public API.

1. Bake a static navigation graph

The navigation graph is immutable at runtime, so it is baked once from a static description:

  1. Create a SubScene and open it.
  2. Add an empty GameObject named Navmesh.
  3. Add the BnMeshAuthoring component.

BnMeshAuthoring builds a flat grid of square polygons with directed portals between axis neighbours, and its baker writes exactly one BnBlobMeshGraph component whose Value points at a BlobAssetReference<BnMeshGraphBlob>.

FieldMeaning
CellsXPolygon count along X.
CellsYPolygon count along Y.
CellSizeWorld-space edge length of one square polygon.
OriginLower-left corner of the grid on the XY navigation plane.

Polygon ids are row-major โ€” id = y * CellsX + x โ€” and never change. A 4 ร— 4 grid with CellSize 1 at Origin (0, 0) covers (0, 0) to (4, 4) and contains 16 polygons.

โš ๏ธ Exactly one graph per world. Both systems skip their work when there is no BnBlobMeshGraph singleton or when more than one exists.

2. Spawn an agent

  1. In the same SubScene, add a GameObject named Agent at (0.5, 0.5, 0).
  2. Add the BnAgentAuthoring component.
  3. Set MaxSpeed to 5, Radius to 0.5 and StartActive to true.

The baker creates the dominant agent archetype in one step:

ComponentPurpose
BnAgentSteeringPosition, velocity, desired velocity, speed, radius and path progress.
BnAgentPathPath slot state and waypoint count.
BnPathWaypointThe path buffer: one element per polygon in the corridor.
BnAgentPathRequestThe pending search request slot.
BnAgentSteeringActiveEnableable toggle for the steering chain.
BnAgentPathRequestPendingEnableable toggle that arms a search request.

The baker sets Start and Target to the spawn position and leaves the request toggle disabled, so the agent stays still until you write a target and arm the request.

3. Systems are discovered automatically

The default world adds both systems to SimulationSystemGroup โ€” nothing to register:

SystemJobOrdering
BnPathfindingSystemBnPathfindJob[UpdateInGroup(SimulationSystemGroup)]
BnSteeringSystemBnFunnelJob, BnSteeringStateJob, KinematicBypassJob, IntegrateJob[UpdateAfter(BnPathfindingSystem)], [UpdateBefore(EndSimulationEntityCommandBufferSystem)]

In a custom World, create both inside its SimulationSystemGroup. Never call OnUpdate manually and never complete their job handles from gameplay code.

4. Request the first path

Add this system to your gameplay assembly. It runs once, writes a target into every baked agent request, and arms the request toggle through the end-of-frame command buffer.

using Unity.Collections;
using Unity.Entities;
using Unity.Mathematics;

namespace BurstNav.Guide
{
    [UpdateInGroup(typeof(SimulationSystemGroup))]
    [UpdateBefore(typeof(BnPathfindingSystem))]
    public partial class BnFirstTargetSystem : SystemBase
    {
        private EndSimulationEntityCommandBufferSystem _commandBufferSystem;
        private EntityQuery _agents;
        private bool _issued;

        protected override void OnCreate()
        {
            _commandBufferSystem = World.GetOrCreateSystemManaged<EndSimulationEntityCommandBufferSystem>();
            _agents = GetEntityQuery(ComponentType.ReadWrite<BnAgentPathRequest>());
        }

        protected override void OnUpdate()
        {
            if (_issued || _agents.IsEmptyIgnoreFilter)
            {
                return;
            }

            _issued = true;

            using var entities = _agents.ToEntityArray(Allocator.Temp);
            using var requests = _agents.ToComponentDataArray<BnAgentPathRequest>(Allocator.Temp);
            var commands = _commandBufferSystem.CreateCommandBuffer();

            for (var index = 0; index < entities.Length; index++)
            {
                var request = requests[index];
                if (request.Status == BnPathStatus.Ready)
                {
                    continue;
                }

                request.Target = new float3(3.5f, 3.5f, 0f);
                request.TargetPoly = -1;
                request.Status = BnPathStatus.Pending;
                request.RequestId++;
                commands.SetComponent(entities[index], request);
                commands.SetComponentEnabled<BnAgentPathRequestPending>(entities[index], true);
            }
        }
    }
}

The command buffer plays back at the end of frame 0. On frame 1 BnPathfindingSystem sees the enabled request, runs flat A* to the nearest polygon of the target, and writes the corridor into the waypoint buffer. The steering system then re-enables BnAgentSteeringActive and the agent starts moving.

Use a payload that matches the baked agent:

FieldValue for the first request
StartKeep the spawn position.
TargetWorld space on the XY plane; Z is height.
TargetPoly-1 asks the pathfinder to snap the target to the nearest polygon.
RequestIdYour own monotonic counter โ€” the pipeline copies it through and never compares it.

5. Verify the first moving agent

Enter Play mode and inspect the Agent entity in the Entities Hierarchy.

FrameWhat you should see
0BnAgentPathRequestPending turns on at the end of the frame.
1BnAgentPath.Status becomes Ready and WaypointCount is greater than zero.
2 and laterBnAgentSteering.Position moves toward (3.5, 3.5, 0); WaypointIndex and PathProgress grow.
ArrivalBnAgentSteering.Flags contains Arrived and DesiredVelocity returns to zero.

If the agent stays still, work through this list in order:

  1. The world has exactly one BnBlobMeshGraph whose Value.IsCreated is true.
  2. The agent carries all six components and its request toggle is enabled.
  3. BnPathfindingSystem and BnSteeringSystem exist and are enabled.
  4. Burst is enabled and the Console shows no job safety errors.
  5. The graph is not empty and a route exists between the resolved polygons.

An off-graph start behaves like an off-graph target: both polygons are snapped to the nearest one. A failure therefore means an empty graph (the snap yields -1), no route, or an exhausted MaxIterations budget โ€” in all three cases BnAgentPath.Status becomes Failed and the corridor is cleared.

6. Build the blob without a SubScene

The same graph can be created from code. Call this one-shot setup before agents run, and dispose the blob when the graph entity is destroyed:

using Unity.Entities;
using Unity.Mathematics;

namespace BurstNav.Guide
{
    public static class BnRuntimeGraph
    {
        public static Entity Create(EntityManager entityManager, int cellsX, int cellsY, float cellSize, float2 origin)
        {
            var blob = BnMeshAuthoringBaker.BuildGraph(cellsX, cellsY, cellSize, origin);
            var entity = entityManager.CreateEntity(typeof(BnBlobMeshGraph));
            entityManager.SetComponentData(entity, new BnBlobMeshGraph { Value = blob });
            return entity;
        }

        public static void Destroy(EntityManager entityManager, Entity entity)
        {
            var blob = entityManager.GetComponentData<BnBlobMeshGraph>(entity).Value;
            if (blob.IsCreated)
            {
                blob.Dispose();
            }

            entityManager.DestroyEntity(entity);
        }
    }
}

BuildGraph returns a persistent blob owned by the caller, unlike the authoring baker whose blob is owned by the baking system. Both Free samples use this path: they build the graph at Play start, so their scenes need no bake step at all.

7. Or start from a sample

Window โ†’ Package Manager โ†’ BurstNav Free โ†’ Samples:

SampleSceneWhat it shows
Hello NavmeshHello Navmesh.unityOne agent patrolling a 4 ร— 4 grid between opposite corners.
Funnel SteeringFunnel Steering.unityFour agents crossing a 6 ร— 6 grid on diagonals; the funnel replaces the stair-step corridor with corner-cutting velocity.

Select the Gizmos object in the Hierarchy to draw the grid, agent spheres and active corridors in the Scene view.

Next step


๐Ÿง  How It Works

BurstNav Free is a small, explicit pipeline: a polygon graph feeds a flat A* search, the search fills a waypoint buffer, and a kinematic funnel turns that corridor into a desired velocity. This page defines the data and the invariants you rely on when you read or extend the code.

๐Ÿงญ Frame flow

BnAgentPathRequest (target written by gameplay, toggle armed)
  -> BnPathfindingSystem / BnPathfindJob
  -> flat A* over BnMeshGraphBlob with one shared BnPathScratchpad
  -> BnAgentPath + BnPathWaypoint buffer (corridor)
  -> BnSteeringSystem / BnFunnel.Solve
  -> BnAgentSteering.DesiredVelocity
  -> KinematicBypassJob
  -> BnAgentSteering.Velocity
  -> IntegrateJob
  -> BnAgentSteering.Position

Two systems, five jobs, six agent components. Nothing else runs.

๐Ÿ—บ๏ธ Graph, polygons and portals

A navigation graph is an immutable polygon soup stored in a blob asset. Every polygon is convex, and two polygons that share an edge are neighbours.

BnMeshGraphBlob stores four flat pools plus per-polygon index tables:

FieldContents
VerticesAll polygon vertices as float2, in graph space on the XY plane.
PolygonsOne BnPolygon per polygon: centre, vertex offset and count, neighbour offset and count.
NeighborPolygonsFlat list of neighbour polygon ids, grouped per polygon.
LinksFlat list of directed portals between neighbours.
PolyLinkOffsetsFirst link index owned by each polygon.
PolyLinkCountsNumber of links leaving each polygon.

Polygon ids are stable integers: Free never reorders or reuses them, so gameplay can store an id and compare it later. Read the graph through its accessors rather than walking the pools:

AccessorReturns
PolygonCount / LinkCount / VertexCountPool sizes.
GetPolygonCenter(id)Polygon centre (heuristic anchor).
GetPolyLinkOffset(id) / GetPolyLinkCount(id)The polygon's slice of Links.
GetPolyLink(id, index)One BnLinkData.
GetNeighborCount(id) / GetNeighbor(id, index)Neighbour polygon ids.
GetVertexCount() / GetVertex(index)Vertex pool access.

A branch-free nearest-polygon query looks like this:

using Unity.Mathematics;

namespace BurstNav.Guide
{
    public static class BnPolygonLookup
    {
        public static int NearestPolygon(ref BnMeshGraphBlob graph, float3 position)
        {
            var point = new float2(position.x, position.y);
            var best = -1;
            var bestDistanceSq = float.PositiveInfinity;

            for (var polygon = 0; polygon < graph.PolygonCount; polygon++)
            {
                var distanceSq = math.distancesq(graph.Polygons[polygon].Center, point);
                var closer = distanceSq < bestDistanceSq;
                best = math.select(best, polygon, closer);
                bestDistanceSq = math.select(bestDistanceSq, distanceSq, closer);
            }

            return best;
        }
    }
}

The scan is sequential over the polygon table and branch-free inside the loop. It suits one-shot queries, not a per-entity hot loop โ€” the pathfinding system resolves world points to polygons once per request.

Links are directed portals

BnLinkData is one directed portal toward a neighbour:

FieldMeaning
PortalLeft / PortalRightEndpoints of the shared edge, in graph space.
TargetPolygon id reached through this portal.
CostTraversal cost. A non-positive cost makes the search use the centre-to-centre distance.

The same edge exists twice when both directions are traversable โ€” each direction is its own BnLinkData entry with its own cost. The funnel reads the portal endpoints, not the polygon centres, which is why a corridor waypoint carries both a position (usually a centre) and an exit point (the portal midpoint used to leave that polygon).

๐Ÿง  Flat A* and the scratchpad

BnAStar.FindPath has one authoritative signature:

bool BnAStar.FindPath(ref BnMeshGraphBlob graph, int startPoly, int targetPoly,
                      ref BnPathScratchpad scratch, int maxIterations)

The heuristic is the Euclidean distance between polygon centres, scaled by BnPathScratchpad.HeuristicScale (default 1, admissible for portal costs). Set it to 0 to degrade to Dijkstra when your cost metric is arbitrary.

The scratchpad is reusable working memory indexed by polygon id. FindPath allocates nothing: a search clears and overwrites the scratchpad arrays in place. Allocate it once with capacity โ‰ฅ graph.PolygonCount, reuse it for every query, and dispose it when the owner is destroyed.

using Unity.Collections;

namespace BurstNav.Guide
{
    public static class BnFlatSearch
    {
        public static BnPathSearchStatus Run(
            ref BnMeshGraphBlob graph,
            int startPoly,
            int targetPoly,
            int maxIterations,
            out float pathCost)
        {
            var scratch = BnPathScratchpad.Create(graph.PolygonCount, Allocator.Temp);
            try
            {
                BnAStar.FindPath(ref graph, startPoly, targetPoly, ref scratch, maxIterations);
                pathCost = scratch.PathCost;
                return scratch.Status;
            }
            finally
            {
                scratch.Dispose();
            }
        }
    }
}
Scratchpad fieldMeaning
StatusOutcome of the last search (BnPathSearchStatus).
Path / PathCountPolygon sequence, start polygon first.
PathCostTotal cost of the found path.
IterationsNumber of expanded polygons โ€” compare it against your budget.
BnPathSearchStatusMeaning
FoundA path is available in the scratchpad.
UnreachableThe open set drained without reaching the target.
BudgetExhaustedmaxIterations ran out before the target was expanded.
InvalidInputA polygon id is outside the graph.
CapacityExceededThe scratchpad is smaller than the graph.

The pathfinding system maps every failed search to BnPathStatus.Failed and clears the agent corridor. A budget cut-off is a failure, not a partial path.

๐Ÿ“ฆ Corridor and waypoints

BnAgentPath is the per-agent path slot:

FieldMeaning
PathIndexStable integer identity of the slot.
WaypointCountNumber of valid elements in the buffer.
StatusNone, Pending, Ready, Partial or Failed.
IsFollowableTrue when the count is positive and the status is Ready or Partial.

BnPathWaypoint is one corridor element:

FieldMeaning
PositionWaypoint position on the navigation plane; the last element is the exact target.
ExitPointPortal midpoint used to leave PolyIndex; equals Position for the last element.
PolyIndexPolygon that owns this waypoint.
LinkIndexIndex into the graph link table, or -1 for the final waypoint.

The pathfinder writes one element per polygon in the sequence, so a corridor with n polygons has n waypoints. Elements are blittable and live in an IBufferElementData buffer with an inline capacity of 16 (BnAgentComponents.DefaultPathCapacity) before spilling to heap storage.

๐ŸŽฏ Kinematic funnel

BnFunnel is a string-pulling solver over the portal corridor. Each frame Solve:

  1. Advances the cursor past every portal the agent has already crossed (AdvancePathProgress).
  2. Tightens a left/right cone from the agent position through the remaining portals.
  3. Returns the first funnel corner, or the final waypoint when the string stays straight.

It then writes a planar desired velocity:

direction = normalize(waypoint - position)
DesiredVelocity = direction * Min(MaxSpeed, distance / deltaTime)

Because of the distance / deltaTime clamp an agent cannot overshoot a waypoint at the end of a frame. Z is height and is never steered: DesiredVelocity.z is always zero. When the agent is within max(Radius, 0.05) of the last waypoint, Solve writes a zero desired velocity and sets BnAgentFlags.Arrived.

๐Ÿ’ก The arrival tolerance is not a separate field. It is the larger of the agent Radius and BnFunnel.DefaultArrivalRadius (0.05), which keeps a zero-radius agent from jittering on the final point.

Progress tracking

FieldMeaning
WaypointIndexCursor into the path buffer โ€” the waypoint the funnel steers toward.
PathProgress / PathLengthDistance travelled along completed segments and total path length.
FlagsFollowing, Arrived and Blocked bits.
NormalizedProgressSaturated PathProgress / PathLength, or 0 without a path.

AdvancePathProgress moves WaypointIndex forward when the agent crosses the portal separating the current waypoint from the next, and rewrites PathProgress to the sum of completed segment lengths. Solve calls it automatically, so gameplay only reads these fields.

๐Ÿƒ Kinematic bypass, and why there is no avoidance

Velocity is resolved by KinematicBypassJob, which is intentionally a direct copy:

Velocity = DesiredVelocity

There is no neighbour query, no broadphase and no velocity-obstacle solve in this stage. An agent follows its funnel exactly and treats every other agent as non-existent: two agents on crossing paths can overlap, and a stopped agent never pushes a moving one aside.

This is a deliberate package boundary, not a tuning gap:

IntegrateJob then advances the position branch-free:

Position = math.mad(Velocity, DeltaTime, Position)

๐Ÿงฉ Why every stage is job-shaped

JobSchedulingWhy
BnPathfindJobSingle-threadedAll agents share one A* scratchpad.
BnFunnelJobParallelEvery agent owns its steering value and buffer.
BnSteeringStateJobParallelWrites enableable toggles into a ParallelWriter.
KinematicBypassJobParallelPure per-agent copy.
IntegrateJobParallelPure per-agent integration.

No system calls Complete inside OnUpdate; dependencies are chained through SystemBase.Dependency, and enableable commands are played back once at the end of simulation.

Next


๐Ÿ“ก Runtime API

Everything below lives in the BurstNav namespace and compiles against SnivelerCode.BurstNav.Runtime. The API is deliberately small: six agent components, one graph component, two static solvers (BnAStar, BnFunnel), two systems and five jobs.

๐Ÿงพ Components at a glance

ComponentKindFields
BnAgentSteeringIComponentDataPosition: float3, Velocity: float3, DesiredVelocity: float3, MaxSpeed: float, Radius: float, PathProgress: float, PathLength: float, WaypointIndex: int, Flags: BnAgentFlags
BnAgentPathIComponentDataPathIndex: int, WaypointCount: int, Status: BnPathStatus
BnPathWaypointIBufferElementDataPosition: float3, ExitPoint: float3, PolyIndex: int, LinkIndex: int
BnAgentPathRequestIComponentDataStart: float3, Target: float3, RequestId: uint, StartPoly: int, TargetPoly: int, Status: BnPathStatus
BnAgentSteeringActiveIComponentData, IEnableableComponentnone โ€” chunk enable bit
BnAgentPathRequestPendingIComponentData, IEnableableComponentnone โ€” chunk enable bit
BnBlobMeshGraphIComponentDataValue: BlobAssetReference<BnMeshGraphBlob>

Active bits are the point: enabling or disabling an IEnableableComponent flips a bit in the chunk mask and moves no entity between archetypes, so a toggle costs nothing in memory or chunk churn.

๐Ÿ” The request lifecycle

// 1. Write the request (main thread or a system, before BnPathfindingSystem)
var request = entityManager.GetComponentData<BnAgentPathRequest>(agent);
request.Start = currentPosition;
request.Target = destination;
request.TargetPoly = -1;                 // -1 = snap to the nearest polygon
request.Status = BnPathStatus.Pending;
request.RequestId++;
entityManager.SetComponentData(agent, request);

// 2. Arm the toggle
entityManager.SetComponentEnabled<BnAgentPathRequestPending>(agent, true);
StepWho does itResult
Write target + arm togglegameplayBnAgentPathRequest.Status = Pending
BnPathfindJobBnPathfindingSystemsnaps Start/Target to polygons, runs A*, fills the buffer
Toggle playbackend-of-frame ECBBnAgentPathRequestPending disabled again
BnPathStatus.Readypath slotcorridor is followable
BnSteeringStateJobBnSteeringSystemre-enables BnAgentSteeringActive for followable agents
BnPathStatusMeaning
NoneNo request issued yet (freshly baked agent).
PendingRequest armed, not yet resolved.
ReadyA corridor is available and followable.
PartialReserved for a partial result; Free never produces one.
FailedEmpty graph, unreachable target, or exhausted budget. Corridor cleared.

โš ๏ธ RequestId is yours alone.BnPathfindJob copies it through untouched and never compares it, so the pipeline cannot detect a stale result for you. If you issue overlapping requests, compare the id after the status becomes Ready.

๐Ÿง  Running a search yourself

BnAStar.FindPath is a public static and Burst-callable:

bool BnAStar.FindPath(ref BnMeshGraphBlob graph, int startPoly, int targetPoly,
                      ref BnPathScratchpad scratch, int maxIterations)
public void Search(ref BnMeshGraphBlob graph, ref BnPathScratchpad scratch, int start, int target)
{
    if (!BnAStar.FindPath(ref graph, start, target, ref scratch, 4096))
    {
        var reason = scratch.Status; // Unreachable / BudgetExhausted / InvalidInput / CapacityExceeded
        return;
    }

    for (var index = 0; index < scratch.PathCount; index++)
    {
        var polygon = scratch.GetPathPolygon(index);
        // use the polygon id
    }
}

Ownership rules for the scratchpad:

Filtered overloads exist on the same method for searches you run yourself:

bool FindPath(ref BnMeshGraphBlob graph, int startPoly, int targetPoly, ref BnPathScratchpad scratch,
              BnLinkFilter filter, int maxIterations)
bool FindPath(ref BnMeshGraphBlob graph, int startPoly, int targetPoly, ref BnPathScratchpad scratch,
              BnLinkFilter filter, NativeArray<ushort> linkTagMasks, int maxIterations)

BnLinkFilter.PassThrough (the default value) allows every link; a non-zero IgnoreTagged rejects every link with any tag bit; otherwise a link is rejected only when one of its tag bits is inside BlockedTagMask, and AllowBlockedTags waives that block. The Free systems always call the unfiltered overload.

๐ŸŽฏ Solving steering yourself

BnFunnel is the string-pulling solver used by BnFunnelJob:

public static void Solve(ref BnAgentSteering steering, ref BnAgentPath path,
                         in DynamicBuffer<BnPathWaypoint> waypoints,
                         ref BnMeshGraphBlob graph, float deltaTime)
// Inside a job, on chunk arrays:
BnFunnel.Solve(ref steering, ref path, in waypoints, ref graph, deltaTime);
Overload pairUse
DynamicBuffer<BnPathWaypoint> / NativeArray<BnPathWaypoint>Same semantics; pick what your call site has.
With / without deltaTimeWithout it, deltaTime is 0, so the desired speed is the full MaxSpeed.

Related statics:

MethodReturns
BnFunnel.AdvancePathProgress(ref steering, ref path, waypoints, ref graph, arrivalRadius)New waypoint index; also rewrites PathProgress/PathLength.
BnFunnel.GetNextWaypoint(ref graph, corridor, startIndex, agentPosition, targetPosition)The next funnel corner as float3.

All of them allocate nothing and own no memory. Solve and AdvancePathProgress write steering and path.WaypointCount; the waypoint buffer and the graph are read-only.

๐Ÿงฑ Creating agents from code

Without authoring components, create the same archetype:

var archetype = BnAgentComponents.CreateAgentArchetype(entityManager);
var agent = entityManager.CreateEntity(archetype);

entityManager.SetComponentData(agent, BnAgentSteering.Idle(position, maxSpeed: 5f, radius: 0.5f));
entityManager.SetComponentData(agent, new BnAgentPath
{
    PathIndex = 0,
    WaypointCount = 0,
    Status = BnPathStatus.None,
});
entityManager.SetComponentData(agent, new BnAgentPathRequest
{
    Start = position,
    Target = position,
    RequestId = 0,
    StartPoly = -1,
    TargetPoly = -1,
    Status = BnPathStatus.None,
});
entityManager.SetBuffer<BnPathWaypoint>(agent);
entityManager.SetComponentEnabled<BnAgentSteeringActive>(agent, true);
entityManager.SetComponentEnabled<BnAgentPathRequestPending>(agent, false);

BnAgentSteering.Idle(position, maxSpeed, radius) returns zero velocity, BnAgentFlags.None and no path. Call CreateAgentArchetype during world setup, never per frame.

๐Ÿšฉ Flags and progress

MemberMeaning
BnAgentFlags.FollowingActive path following.
BnAgentFlags.ArrivedFinal waypoint reached; DesiredVelocity is zero.
BnAgentFlags.BlockedReserved for gameplay โ€” no Free code sets or reads it.
BnAgentSteering.HasPathPathLength > 0 && (Flags & Following) != 0.
BnAgentSteering.NormalizedProgressPathProgress / PathLength saturated to 0..1, or 0 without a path.
BnAgentPath.IsFollowable`WaypointCount > 0 && (Status == Ready

Both enums are byte-backed so the containing structs stay blittable and compact.

๐Ÿ“ฆ Reading the graph

MemberReturns
PolygonCount, LinkCount, VertexCountPool sizes.
GetPolygonCenter(int id)float2 centre.
GetPolyLinkOffset(int id), GetPolyLinkCount(int id)The polygon's link slice.
GetPolyLink(int id, int index)BnLinkData (PortalLeft, PortalRight, Target, Cost).
GetNeighborCount(int id), GetNeighbor(int id, int index)Neighbour id.
GetVertex(int index)float2 vertex.

The blob is immutable and safe to read from parallel jobs without a job dependency of its own.

See also


๐Ÿงฉ Components & Systems

This page is the complete contract: every component layout, every job's inputs and outputs, and the order the systems run in.

๐Ÿงพ Graph component

TypeKindFields
BnBlobMeshGraphIComponentDataValue: BlobAssetReference<BnMeshGraphBlob>

The component grants one entity ownership of an immutable navigation graph. The blob reference keeps topology out of the component, so a job reads the graph without copying arrays or resolving components per agent. The world owns the component; whoever created the blob owns and disposes the reference.

๐Ÿค– Agent archetype

BnAgentComponents.CreateAgentArchetype(EntityManager) produces exactly one archetype:

ComponentTypeWritten by
BnAgentSteeringIComponentDataBnFunnelJob, KinematicBypassJob, IntegrateJob
BnAgentPathIComponentDataBnPathfindJob, BnFunnelJob
BnPathWaypointIBufferElementDataBnPathfindJob
BnAgentPathRequestIComponentDatagameplay, BnPathfindJob
BnAgentSteeringActiveIEnableableComponentBnSteeringStateJob (via ECB)
BnAgentPathRequestPendingIEnableableComponentBnPathfindJob (via ECB)

๐Ÿ’ก One archetype, always. Do not add optional marker components per agent โ€” every extra component splits the logical agent into a new archetype and costs you chunk density. If you need a gameplay flag, put it in BnAgentFlags.Blocked or in a component that every agent has.

BnAgentComponents.DefaultPathCapacity is 16: the inline BnPathWaypoint capacity before the buffer spills to heap storage. A corridor longer than 16 polygons allocates once for that agent โ€” the only heap traffic in the whole pipeline, and it only happens on long paths.

๐Ÿ” BnAgentSteering in detail

FieldMeaningOwner
PositionWorld position. XY is the navigation plane, Z is height.IntegrateJob
VelocityResolved velocity.KinematicBypassJob
DesiredVelocityRequested velocity from the funnel.BnFunnel.Solve
MaxSpeedUpper bound in units per second.authored
RadiusAgent radius โ€” also the arrival tolerance.authored
PathProgress / PathLengthCompleted segment length and total length.BnFunnel
WaypointIndexCursor into the corridor.BnFunnel
FlagsFollowing, Arrived, Blocked.BnFunnel
MemberSemantics
Idle(float3 position, float maxSpeed, float radius)Zero velocity, BnAgentFlags.None, no path.
HasPathPathLength > 0 && (Flags & Following) != 0.
NormalizedProgressPathProgress / PathLength saturated to 0..1, or 0 without a path.

Both properties are branch-free, read-only and take no allocation.

โš ๏ธ Never write PathProgress, PathLength or WaypointIndex. The funnel owns them; overwriting them corrupts the cursor and makes the agent walk backwards along its corridor.

๐Ÿง  Also worth knowing

TypeFieldsNotes
BnPathWaypointPosition, ExitPoint, PolyIndex, LinkIndexCreate(position, exitPoint, polyIndex, linkIndex) copies the four arguments unchanged. LinkIndex = -1 on the final waypoint.
BnAgentPathRequestStart, Target, RequestId, StartPoly, TargetPoly, StatusCreate(start, target, requestId) starts as Pending with both polygon ids at -1.
BnAgentPathPathIndex, WaypointCount, StatusPathIndex is a stable identity you assign; Free never renumbers it.
BnPolygonCenter, VertexOffset, VertexCount, NeighborOffset, NeighborCountBlob struct, read-only after bake.
BnLinkDataPortalLeft, PortalRight, Target, CostBlob struct; Cost <= 0 means "use centre-to-centre distance".

โš™๏ธ Jobs

JobInterfaceInputOutput
BnPathfindJobIJobChunkBnAgentPathRequest, BnAgentPath, BnPathWaypoint buffer, enabled BnAgentPathRequestPending, graph singletonBnAgentPathRequest, BnAgentPath, waypoint buffer, SetComponentEnabled<BnAgentPathRequestPending>(false)
BnFunnelJobIJobChunkBnAgentSteering, BnAgentPath, waypoint buffer, BnAgentSteeringActive, graph singletonBnAgentSteering
BnSteeringStateJobIJobChunkBnAgentPath, BnAgentSteeringActiveSetComponentEnabled<BnAgentSteeringActive> commands
KinematicBypassJobIJobChunkBnAgentSteering (active query)BnAgentSteering.Velocity
IntegrateJobIJobChunkBnAgentSteering (active query)BnAgentSteering.Position

Behavioural details that are easy to miss:

๐Ÿ—๏ธ Systems

SystemGroupFieldsOwns
BnPathfindingSystemSimulationSystemGroupMaxIterations (default DefaultMaxIterations = 4096), properties HasScratchpad, ScratchpadCapacityone persistent BnPathScratchpad
BnSteeringSystemSimulationSystemGroup, [UpdateAfter(BnPathfindingSystem)], [UpdateBefore(EndSimulationEntityCommandBufferSystem)]noneno native memory

System order

OrderWhoWork
1your tuning system (InitializationSystemGroup)one-shot field assignment
2your request system (SimulationSystemGroup, before BnPathfindingSystem)write target, arm the request
3BnPathfindingSystemflat A* and corridor write
4BnSteeringSystemfunnel โ†’ bypass โ†’ integrate
5EndSimulationEntityCommandBufferSystemsingle command playback

BnPathfindingSystem declares only [UpdateInGroup]; its command buffer is ordered by AddJobHandleForProducer, which makes the barrier wait for the pathfind job instead of relying on an UpdateBefore attribute. BnSteeringSystem registers its final handle with the same barrier, so both toggle changes play back once per frame.

Scratchpad resizing

When a bound graph outgrows the scratchpad, EnsureScratchpad allocates a new one, swaps it in, and calls Dispose(JobHandle) on the old arrays with the in-flight search handle. The update is never skipped and the system never calls Complete on the main thread. Never resize or dispose that scratchpad from gameplay code.

๐Ÿงต Threading rules that keep the pipeline valid

RuleWhy
Never call Complete() on the pathfinding or steering handles from OnUpdateSerializes the frame; read the components on a later frame instead.
Read and write components through chunk arrays, never per-entity GetComponentData in a loopEach per-entity call is a random memory access into archetype storage.
Let the systems own the EntityCommandBuffer playbackOne playback at frame end keeps toggles consistent within a frame.
Keep exactly one BnBlobMeshGraph singletonBoth systems early-out on zero or multiple matches.
Keep one dominant agent archetypeDenser chunks, better L1/L2 hit ratio during iteration.

See also


๐Ÿ“ฆ Mesh Graph Blob Format

The navigation graph is a single blob asset. This page lists exactly what is inside it, how big it is, and the rules that keep it valid.

๐Ÿงฑ The seven pools

BnMeshGraphBlob
โ”œโ”€โ”€ Vertices        : BlobArray<float2>       // all polygon corners, graph space (XY)
โ”œโ”€โ”€ Polygons        : BlobArray<BnPolygon>    // centre + vertex/neighbour slices
โ”œโ”€โ”€ NeighborPolygons: BlobArray<int>          // neighbour ids, grouped per polygon
โ”œโ”€โ”€ Links           : BlobArray<BnLinkData>   // directed portals
โ”œโ”€โ”€ PolyLinkOffsets : BlobArray<int>          // first link index per polygon
โ””โ”€โ”€ PolyLinkCounts  : BlobArray<int>          // links leaving each polygon

Access is always offset + count pairs, never a linked structure: A* walks the link pool sequentially from PolyLinkOffsets[polygon] for PolyLinkCounts[polygon] entries, which is exactly what Burst needs to vectorize and prefetch.

๐Ÿ“ Struct sizes

StructFieldsBytes
BnPolygonCenter: float2 (8) + VertexOffset: int (4) + VertexCount: int (4) + NeighborOffset: int (4) + NeighborCount: int (4)24
BnLinkDataPortalLeft: float2 (8) + PortalRight: float2 (8) + Target: int (4) + Cost: float (4)24
vertexfloat28

Field order is already size-descending (8-byte, then 4-byte members), so no alignment padding is inserted.

๐Ÿ”ข Pool sizes for a grid

BnMeshAuthoringBaker.BuildGraph emits a non-indexed grid: each polygon owns its own four vertices and all links are materialised in both directions.

PoolSize for CellsX ร— CellsY
PolygonsX * Y
Vertices4 * X * Y
Links2 * ((X-1) * Y + X * (Y-1))
NeighborPolygonssame as Links
PolyLinkOffsets / PolyLinkCountsX * Y each

Polygon id is row-major: id = y * CellsX + x. The four vertices of polygon id are its lower-left corner, then clockwise: (x, y), (x+1, y), (x+1, y+1), (x, y+1), scaled by CellSize and offset by Origin.

Example: 4 ร— 4 grid, CellSize = 1

PoolCountBytes
Polygons16384
Vertices64512
Links24576
NeighborPolygons2496
PolyLinkOffsets1664
PolyLinkCounts1664
Total (payload)โ‰ˆ 1.7 KB

Example: 100 ร— 100 grid, CellSize = 1

PoolCountBytes
Polygons10 000โ‰ˆ 234 KB
Vertices40 000โ‰ˆ 313 KB
Links39 600โ‰ˆ 928 KB
NeighborPolygons39 600โ‰ˆ 155 KB
PolyLinkOffsets + PolyLinkCounts10 000 eachโ‰ˆ 78 KB
Total (payload)โ‰ˆ 1.7 MB

Add roughly 29 bytes per polygon for the A* scratchpad (โ‰ˆ 290 KB here), and keep in mind both live for the whole level.

๐Ÿ’ก Vertex duplication is the price of a non-indexed grid. Sharing corners between polygons would cut Vertices by ~4ร—, but the blob would need an index pool and the funnel would lose its direct corner reads. At the sizes Free targets, the duplication is cheaper than the indirection.

๐Ÿ”’ Immutability rules

RuleConsequence of breaking it
The blob never changes after CreateBlobAssetReferenceJobs read it without a job dependency of their own.
Exactly one BnBlobMeshGraph per worldBoth systems early-out on zero or multiple matches โ€” the pipeline silently stops.
The creator disposes the blobAuthoring-baked blobs are owned by the baking system; BuildGraph blobs are yours to Dispose().
Never swap the blob while searches are in flightExisting corridors reference polygon ids that a new blob may no longer contain.

๐Ÿ› ๏ธ Building a blob yourself

Only BnMeshAuthoringBaker.BuildGraph(cellsX, cellsY, cellSize, origin) is public; the BlobBuilder path is internal. That means custom geometry has two options:

  1. Compose from grids. Bake several BnMeshAuthoring entities โ€” each produces its own graph, but only one may be the singleton, so grids are usually combined into a single level grid instead.
  2. Write your own builder. Build a BnMeshGraphBlob with BlobBuilder, keeping the invariants below, then assign it to a BnBlobMeshGraph entity.

Invariants for a hand-built blob

InvariantCheck
Every BnPolygon is convexThe funnel assumes convex portals between neighbours.
Target of every link is a valid polygon id0 <= Target < PolygonCount.
PolyLinkOffsets[p] + PolyLinkCounts[p] <= LinkCountNo slice may overrun the link pool.
VertexOffset + VertexCount <= VertexCount (the pool length)Vertex slices must stay in the pool.
NeighborOffset + NeighborCount <= NeighborPolygons.LengthNeighbour slices must stay in the pool.
Link order matches neighbour orderGetNeighbor(p, i) should be the polygon reached by GetPolyLink(p, i).
PortalLeft/PortalRight are the shared edgeThe funnel reads portal midpoints, not polygon centres.
A non-positive Cost is intentionalIt means "use centre-to-centre distance".

โš ๏ธ A malformed blob does not throw. The search will still run and produce a corridor that the funnel cannot follow, so validate custom blobs with a one-off EditMode test against a small grid.

๐Ÿง  Scratchpad layout (for reference)

BnPathScratchpad is not uniformly indexed โ€” the distinction matters if you inspect it:

ArrayLengthIndexed by
GScore, CameFrom, HeapSlots, Closed, PathCapacitypolygon id
HeapPolygons, HeapKeysCapacity + 1heap slot (extra slot allows a speculative push without a bounds check)
VisitStampCapacity + 1polygon id (last slot holds SearchId)

VisitStamp plus SearchId is how a new search invalidates the previous one by incrementing a counter instead of clearing five arrays. When the counter wraps, the rest of the array is cleared once. HeuristicScale survives EnsureCapacity; every other field is search state.

See also


๐ŸŽ๏ธ Performance & Tuning

The Free package has few tuning knobs on purpose: the search budget bounds worst-case pathfinding, and the agent steering fields define speed and stopping distance. Everything else is fixed by the zero-allocation job pipeline.

๐Ÿ“Š Cost model

StageComplexityThreading
Polygon resolve + flat A*O(expanded polygons) per requestsingle-threaded (one shared scratchpad)
Corridor writeO(corridor length)same job
Funnel + progressO(corridor length) per agentparallel
BypassO(1) per agentparallel
IntegrateO(1) per agentparallel

Pathfinding dominates, and it is serializer-bound by design: two searches cannot share one scratchpad. Steering, by contrast, scales linearly across cores because each agent owns its state and buffer.

Steady-state allocations are zero. The only heap traffic in the pipeline is a BnPathWaypoint buffer spilling past its inline capacity of 16 when a corridor is longer than 16 polygons โ€” and only once per agent.

๐ŸŽš๏ธ MaxIterations

BnPathfindingSystem.MaxIterations is the maximum number of A* node expansions per request. Default: DefaultMaxIterations = 4096.

ValueEffect
Too lowLong paths end as BnPathStatus.Failed and the corridor is cleared.
4096 (default)Covers most levels up to a few thousand polygons.
LargerTolerates longer or more obstructed routes, but bounds a bad request less tightly.

One expansion pops one polygon and relaxes its outgoing links, so the budget only has to exceed the number of polygons the search expands before it reaches the target. An unreachable target drains the open set and stops early, which costs at most one expansion per reachable polygon. A budget cut-off is a separate outcome.

Set the field once, before agents start requesting paths:

using Unity.Entities;

namespace BurstNav.Guide
{
    [UpdateInGroup(typeof(InitializationSystemGroup))]
    public partial class BnTuningSystem : SystemBase
    {
        private bool _applied;

        protected override void OnUpdate()
        {
            if (_applied)
            {
                return;
            }

            _applied = true;
            var pathfinding = World.GetOrCreateSystemManaged<BnPathfindingSystem>();
            pathfinding.MaxIterations = 8192;
        }
    }
}

HasScratchpad and ScratchpadCapacity let you assert at startup that the scratchpad covers the graph instead of discovering it on the first long request.

๐Ÿงฎ Memory

AllocationLifetimeSize
Graph bloblevelsee Mesh Graph Blob Format
A* scratchpad (system-owned)levelโ‰ˆ 29 bytes per polygon + 12 bytes of spare slots
Waypoint buffersper agent16 inline elements, then heap

The scratchpad is allocated once per graph size, not per frame. When the graph outgrows it, the system allocates a replacement and retires the old arrays with Dispose(JobHandle) โ€” never by completing the in-flight search on the main thread.

๐Ÿƒ Speed and arrival

FieldEffect
MaxSpeedUpper bound of DesiredVelocity and Velocity, units per second.
RadiusAgent radius; also the effective arrival tolerance.

The funnel computes desired speed as Min(MaxSpeed, distance / deltaTime), so an agent cannot overshoot a waypoint at the end of a frame. The arrival test uses max(Radius, BnFunnel.DefaultArrivalRadius) โ€” a larger Radius stops the agent further from the target, and a Radius below 0.05 still stops at 0.05.

๐Ÿ’ก There is no acceleration model. The kinematic bypass changes velocity from zero to MaxSpeed in one frame. For smoother motion, lower MaxSpeed or replace the steering chain with your own acceleration-limited version before integration.

Changing the profile after baking is a one-shot write, never a per-frame edit:

using Unity.Entities;

namespace BurstNav.Guide
{
    public static class BnAgentProfile
    {
        public static void Apply(EntityManager entityManager, Entity agent, float maxSpeed, float radius)
        {
            var steering = entityManager.GetComponentData<BnAgentSteering>(agent);
            steering.MaxSpeed = maxSpeed;
            steering.Radius = radius;
            entityManager.SetComponentData(agent, steering);
        }
    }
}

Read PathProgress, PathLength, NormalizedProgress and WaypointIndex for HUDs and logic; never write them.

โš™๏ธ Burst and Jobs settings

Editor settingDevelopmentShip
Jobs โ†’ Burst โ†’ Enable Compilationonon
Jobs โ†’ Burst โ†’ Synchronous Compilationonly when debugging Burst codeoff
Jobs โ†’ Safety Checksonoff in release
Jobs โ†’ Leak Detectiononon in development builds

Runtime rules that keep the pipeline valid:

๐Ÿ”ฌ Measuring instead of guessing

QuestionWhere to look
Is pathfinding the frame cost?Profiler โ†’ Hierarchy โ†’ BnPathfindingSystem, or the Jobs breakdown for BnPathfindJob.
Are long paths failing?Inspect BnAgentPath.Status and compare scratch.Iterations with MaxIterations.
Are agents overlapping?Expected โ€” see Limitations & Scope. There is no separation stage to tune.
Are buffers spilling?Entities Hierarchy โ†’ agent โ†’ BnPathWaypoint capacity vs WaypointCount.
Is the graph too big?Count polygons: LinkCount and PolygonCount on the blob; compare against the budget table above.

๐Ÿš€ Optimisation order

If the profile says pathfinding is too slow for your level, in this order:

  1. Reduce graph size. Bigger CellSize means fewer, larger polygons โ€” the same level with a quarter of the polygons runs roughly four times cheaper per search.
  2. Request less often. Paths are static; re-request only on a new destination, not every frame.
  3. Raise the budget only after measuring.MaxIterations does not make searches faster โ€” it makes more of them succeed.
  4. Spread requests over frames. One or two long searches per frame keeps a stable frame time; a burst of 50 identical long searches does not.
  5. Replace the pathfinding stage if you need hierarchical search or filtered long routes. That is an architecture change, not a setting.

See also


โš ๏ธ Limitations & Scope

Free is built for small static levels with a modest number of agents. The limits below follow directly from the architecture, so plan around them instead of trying to tune them away.

๐Ÿ“‰ Flat search scaling

Every request runs one flat A* over the whole polygon graph. Cost grows with the number of expanded polygons, and every agent searches the same graph from scratch โ€” there is no cluster decomposition, no abstract graph and no precomputed long-distance route table.

Graph sizeBehaviour
Tens to a few thousand polygonsThe default 4096-expansion budget covers typical paths.
Several thousand polygonsRaise MaxIterations or long routes may fail.
Tens of thousands of polygonsEach request becomes expensive, and the scratchpad grows with the graph.

The scratchpad is O(polygon count) in memory โ€” roughly 29 bytes per polygon plus 12 bytes of spare heap and visit-stamp slots. It is reused, so it never allocates per frame, but it must cover the whole graph: a large graph has a fixed memory floor even when agents only travel short distances.

Pathfinding is also all-or-nothing. When the budget runs out, the request becomes BnPathStatus.Failed and the corridor is cleared โ€” Free never emits a partial path for the agent to follow toward the target.

๐Ÿ‘ฅ No crowd avoidance

Free has no neighbour query and no local avoidance solve. KinematicBypassJob copies DesiredVelocity into Velocity unchanged, so every agent follows its funnel as if no other agent existed.

Observable effects:

The funnel still produces smooth single-agent paths through portal edges. What is missing is social: nothing in Free reads another agent's position or velocity during steering.

If your design needs separation, provide it outside the runtime โ€” spaced spawn points, one-way lanes, staggered start times. A custom post-steering separation job replaces the Free steering contract and is therefore not part of the supported pipeline.

๐Ÿงฑ No dynamic obstacles

The navigation graph is an immutable blob asset. There is no runtime obstacle store, no obstacle query and no broadphase to update when a blocker moves.

You can bake a different graph for a different level state, but swapping graphs at runtime invalidates existing corridors and can force every agent to repath. That is not a supported dynamic-obstacle workflow.

๐Ÿšช No door or area tags

Free links carry no door or area tags, and BnPathfindingSystem always runs the unfiltered A* overload. Every portal in the graph is traversable.

BnAStar.FindPath does expose filtered overloads that take a BnLinkFilter plus an optional per-link tag-mask array, and BnLinkFilter ships in this assembly. Using them requires your own job or system: BnPathfindJob always passes BnLinkFilter.PassThrough with no tag masks, so a filtered search is not reachable through BnPathfindingSystem.

๐ŸŒ Static graph, one owner

Free assumes one static graph per world:

๐Ÿ“ 2.5-D navigation

Paths and steering are solved on XZ only:

๐Ÿงฉ Choosing the right tool

Your level needsFreeNotes
Dozens of agents on a static gridโœ…The intended use case.
A few thousand polygons with short routesโœ…Keep MaxIterations โ‰ฅ reachable polygon count.
Crowds that queue at doorsโŒNo separation stage to tune.
Obstacles that move mid-gameโŒGraph is immutable.
Per-agent door accessโŒNo link tags in the pipeline.
One agent, one corridor, zero allocationโœ…100 % Burst, no main-thread sync.

๐Ÿ”ง Extending beyond Free

Free stops at the architecture on this page. If a level needs more, the options are:

Each option replaces a pipeline stage rather than changing a field, because the package deliberately exposes no extension points: six agent components, five jobs and two systems are the whole contract.

Where to go next


๐Ÿš‘ Troubleshooting & FAQ

๐Ÿ” Agent does not move

Work through this list in order โ€” it covers every cause we know of.

#CheckFix
1Is there exactly one BnBlobMeshGraph with Value.IsCreated?Bake the graph in a SubScene, or call BnMeshAuthoringBaker.BuildGraph once at startup.
2Does the agent carry all six components?Use BnAgentAuthoring or BnAgentComponents.CreateAgentArchetype.
3Is BnAgentPathRequestPending enabled?Enable it after writing a target โ€” a freshly baked agent has it off by design.
4Did you write a Target different from Start?The baker sets both to the spawn position.
5Are BnPathfindingSystem and BnSteeringSystem present and enabled?Check Window โ†’ Entities โ†’ Systems; in a custom world, create both inside SimulationSystemGroup.
6Is BnAgentSteeringActive enabled?BnSteeringStateJob turns it on when a path becomes followable; a manual false keeps the agent frozen.
7Is Burst enabled with no job safety errors?Fix the first console error before anything else.

โŒ BnAgentPath.Status is Failed

Three causes, in order of likelihood:

CauseSymptomFix
No route between the resolved polygonsStartPoly/TargetPoly are valid but disconnectedCheck the graph actually connects those regions; a grid graph with CellsX = 1 cannot go sideways.
Budget exhaustedscratch.Iterations == MaxIterationsRaise BnPathfindingSystem.MaxIterations.
Empty graphPolygonCount == 0, so both snaps return -1The bake produced nothing: CellsX/CellsY are clamped to at least 1, so check that the entity was actually baked.

Remember that a failed search clears the corridor โ€” the agent stops rather than following a partial path. That is intentional.

๐Ÿงญ The agent walks in a straight line through walls

CauseFix
Z was used as the navigation planePathfinding is XZ only: put the level on XZ and use Y for height.
The graph sits somewhere else than the levelOrigin and CellSize of BnMeshAuthoring must match the visual layout.
Corridor waypoints were edited by gameplayNever write BnPathWaypoint or PathProgress; both are owned by the pipeline.

๐Ÿ‘ฅ Agents pass through each other

That is the documented behaviour. KinematicBypassJob copies DesiredVelocity into Velocity and reads no neighbour data, so Free has no separation stage. Use spaced spawn points, one-way lanes, staggered start times, or replace the steering system โ€” see Limitations & Scope.

๐Ÿšง Moving obstacles are ignored

The graph is an immutable blob and there is no obstacle store. Rebuild the blob for a new level state, or keep obstacles out of the walkable graph. There is no push-out when an agent overlaps a blocker.

๐Ÿšช Doors do not close

Free links carry no tags and the systems always run the unfiltered search. Enforce access in gameplay before issuing a request, or write a custom job around BnAStar.FindPath's filtered overloads.

๐Ÿงฉ Nothing runs after adding a second graph

Both systems require a singleBnBlobMeshGraph. With two, TryGetSingleton fails and the systems early-out โ€” silently. Check the world for duplicate baked navmesh objects, including graphs imported with a sample.

๐Ÿ“ฆ Sample cannot be found or opens with missing scripts

SymptomFix
No sample in the Samples tabConfirm the package version is 1.1.0 and that package.json lists the sample; refresh Package Manager.
Missing script referencesKeep the generated Scripts folder and its .asmdef intact โ€” it references SnivelerCode.BurstNav.Runtime.
Scene opens with missing scriptsDelete Assets/Samples/BurstNav Free, reimport from the Samples tab, reopen the scene.
Samples~ is not under AssetsExpected โ€” the folder is hidden by design until imported.
Gizmos are invisibleSelect the Gizmos object and enable Gizmos in the Scene view toolbar; drawing is a scene aid only.

๐Ÿงช Tests do not appear in the Test Runner

Package tests compile only when the package is listed under testables:

{
  "testables": ["sniveler-code.dev.burstnav-ecs"]
}

Then run SnivelerCode.BurstNav.Tests.EditMode or SnivelerCode.BurstNav.Tests.PlayMode.

โ“ FAQ

Does Free support slopes, stairs or multiple floors?
No. Navigation is XZ only; the pipeline never modifies agent Y. Vertical movement is your gameplay's job, and a multi-floor level flattens into one plane.

Can I use a custom mesh instead of the grid?
Yes, by writing your own BlobBuilder code that produces a valid BnMeshGraphBlob โ€” see the invariants in Mesh Graph Blob Format. BnMeshAuthoring itself only emits grids.

Can I have two graphs and switch between them?
Not through the Free systems: they require exactly one singleton, and replacing the blob while searches are in flight is unsupported. Build one graph per level.

Is this a NavMesh replacement?
For static, moderate-size levels with per-agent movement, yes. It is not a replacement for crowd simulation, dynamic obstacles or off-mesh links.

Do I need a SubScene?
No. Both samples build the graph from code at Play start (BnMeshAuthoringBaker.BuildGraph). A SubScene is just the convenient path for level designers.

Is the result deterministic?
Yes, given the same graph, the same requests and the same frame delta. BnPathfindJob is single-threaded over a stable polygon ordering, and steering is per-agent with no shared state.

What happens if a corridor is longer than 16 polygons?
The BnPathWaypoint buffer spills from inline storage to the heap once for that agent. Paths of 16 or fewer polygons are allocation-free.

Does RequestId cancel a stale request?
No. It is copied through untouched; compare it yourself if you issue overlapping requests.

Which Unity versions are supported?
Unity 2022.3 and newer with Entities 1.x. It is verified in Unity 6000.5.2f1 with com.unity.entities 6.5.0.

Still stuck?


Edit on GitHub v1.0.0