๐ 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?NavMeshAgentis 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
- ๐ง Static polygon graph in a blob asset โ one immutable
BlobAssetReference<BnMeshGraphBlob>shared by every job. No graph copies, no per-agent topology. - ๐ง Branch-free flat A* โ
BnAStar.FindPathexpands polygons from a single reusableBnPathScratchpad. Steady-state allocation is exactly zero. - ๐ฏ Kinematic funnel steering โ portal-based string pulling (
BnFunnel) removes the stair-step corridor and returns corner-cutting velocity in one pass. - ๐งฉ Six-component agent archetype โ
BnAgentSteering,BnAgentPath,BnPathWaypoint,BnAgentPathRequestplus two enableable toggles. One dominant archetype means dense chunks. - โก Deferred, allocation-free command buffers โ request and steering toggles flip enable bits through
EndSimulationEntityCommandBufferSystem; nothing completes a job on the main thread. - ๐งช EditMode and PlayMode tests โ the package ships a NUnit suite under
Testsplus two runnable samples.
๐งญ 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
| Property | Value |
|---|---|
| Package name | sniveler-code.dev.burstnav-ecs |
| Display name | BurstNav Free |
| Version | 1.1.0 |
| Minimum Unity | 2022.3 |
| Runtime assembly | SnivelerCode.BurstNav.Runtime (root namespace BurstNav) |
| Dependencies | com.unity.entities 1.2.4, com.unity.burst 1.8.12, com.unity.collections 2.4.0, com.unity.mathematics 1.3.1 |
| Verified host | Unity 6000.5.2f1 with com.unity.entities 6.5.0 |
| License | MIT |
| Editor tooling | None โ no windows, no define symbols, no project settings |
๐ What ships in the box
| Layer | Implementation | Main types |
|---|---|---|
| Navigation graph | Static polygon graph in a blob asset | BnMeshGraphBlob, BnPolygon, BnLinkData |
| Graph owner | Singleton component pointing at the blob | BnBlobMeshGraph |
| Search | Flat A* with a fixed iteration budget | BnAStar, BnPathScratchpad, BnLinkFilter |
| Path storage | Per-agent path slot and waypoint buffer | BnAgentPath, BnPathWaypoint |
| Steering | Kinematic funnel over portal edges | BnFunnel |
| Velocity | Kinematic bypass: desired velocity becomes velocity | KinematicBypassJob |
| Integration | Position advanced by velocity and delta time | IntegrateJob |
| Environment | Static navmesh only | BnMeshAuthoring |
| Agent authoring | One dominant agent archetype | BnAgentAuthoring, 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
- Getting Started โ install the package, bake a graph, spawn an agent and issue the first request.
- Core โ the frame-by-frame pipeline and the full runtime API for requests, search and steering.
- Reference โ every component, job and system, the blob memory layout, and the tuning knobs that actually exist.
- Handbook โ the exact scope of Free and a symptom-to-cause troubleshooting table.
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.
| Requirement | Version | Notes |
|---|---|---|
| Unity Engine | 2022.3 or newer | Declared as "unity": "2022.3" in package.json. |
| Unity Entities | 1.2.4 | Pulled in automatically. Verified host: Unity 6000.5.2f1 with com.unity.entities 6.5.0. |
| Burst Compiler | 1.8.12 | Pulled in automatically. |
| Unity Collections | 2.4.0 | Pulled in automatically. |
| Unity Mathematics | 1.3.1 | Pulled in automatically. |
| AI Module | built-in | Not 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
- Open Window โ Package Manager.
- Click + โ Add package from diskโฆ
- Select the
package.jsoninsidesniveler-code.dev.burstnav-ecs. - 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
.metafile. The GUIDs inside them keep serialized references โ authoring components in scenes, subscene references and sample assets โ stable across package updates. Deleting.metafiles makes Unity re-create them with new GUIDs and every baked reference breaks.
Runtime assembly
| Property | Value |
|---|---|
| Assembly name | SnivelerCode.BurstNav.Runtime |
| Root namespace | BurstNav |
allowUnsafeCode | true |
autoReferenced | true |
| References | Unity 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.asmdefbreaks every snippet in this documentation.
Import the samples
- Window โ Package Manager.
- Select BurstNav Free.
- Open the Samples tab.
- 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
| Check | Expected |
|---|---|
| Console | No compile errors, no Burst warnings about SnivelerCode.BurstNav.Runtime. |
| Jobs โ Burst โ Enable Compilation | On (default). |
| Systems | After a scene with a BnBlobMeshGraph runs, BnPathfindingSystem and BnSteeringSystem appear in Window โ Entities โ Systems. |
| Menu bar | There 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:
- Create a SubScene and open it.
- Add an empty GameObject named
Navmesh. - 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>.
| Field | Meaning |
|---|---|
CellsX | Polygon count along X. |
CellsY | Polygon count along Y. |
CellSize | World-space edge length of one square polygon. |
Origin | Lower-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
BnBlobMeshGraphsingleton or when more than one exists.
2. Spawn an agent
- In the same SubScene, add a GameObject named
Agentat (0.5, 0.5, 0). - Add the BnAgentAuthoring component.
- Set
MaxSpeedto 5,Radiusto 0.5 andStartActiveto true.
The baker creates the dominant agent archetype in one step:
| Component | Purpose |
|---|---|
BnAgentSteering | Position, velocity, desired velocity, speed, radius and path progress. |
BnAgentPath | Path slot state and waypoint count. |
BnPathWaypoint | The path buffer: one element per polygon in the corridor. |
BnAgentPathRequest | The pending search request slot. |
BnAgentSteeringActive | Enableable toggle for the steering chain. |
BnAgentPathRequestPending | Enableable 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:
| System | Job | Ordering |
|---|---|---|
BnPathfindingSystem | BnPathfindJob | [UpdateInGroup(SimulationSystemGroup)] |
BnSteeringSystem | BnFunnelJob, 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:
| Field | Value for the first request |
|---|---|
Start | Keep the spawn position. |
Target | World space on the XY plane; Z is height. |
TargetPoly | -1 asks the pathfinder to snap the target to the nearest polygon. |
RequestId | Your 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.
| Frame | What you should see |
|---|---|
| 0 | BnAgentPathRequestPending turns on at the end of the frame. |
| 1 | BnAgentPath.Status becomes Ready and WaypointCount is greater than zero. |
| 2 and later | BnAgentSteering.Position moves toward (3.5, 3.5, 0); WaypointIndex and PathProgress grow. |
| Arrival | BnAgentSteering.Flags contains Arrived and DesiredVelocity returns to zero. |
If the agent stays still, work through this list in order:
- The world has exactly one
BnBlobMeshGraphwhoseValue.IsCreatedis true. - The agent carries all six components and its request toggle is enabled.
BnPathfindingSystemandBnSteeringSystemexist and are enabled.- Burst is enabled and the Console shows no job safety errors.
- 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:
| Sample | Scene | What it shows |
|---|---|---|
| Hello Navmesh | Hello Navmesh.unity | One agent patrolling a 4 ร 4 grid between opposite corners. |
| Funnel Steering | Funnel Steering.unity | Four 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 โ what happens between the request and the integrated position.
- Runtime API โ every component field, the search call and the funnel call.
- Performance & Tuning โ search budget, speed and arrival behaviour.
๐ง 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:
| Field | Contents |
|---|---|
Vertices | All polygon vertices as float2, in graph space on the XY plane. |
Polygons | One BnPolygon per polygon: centre, vertex offset and count, neighbour offset and count. |
NeighborPolygons | Flat list of neighbour polygon ids, grouped per polygon. |
Links | Flat list of directed portals between neighbours. |
PolyLinkOffsets | First link index owned by each polygon. |
PolyLinkCounts | Number 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:
| Accessor | Returns |
|---|---|
PolygonCount / LinkCount / VertexCount | Pool 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:
| Field | Meaning |
|---|---|
PortalLeft / PortalRight | Endpoints of the shared edge, in graph space. |
Target | Polygon id reached through this portal. |
Cost | Traversal 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 field | Meaning |
|---|---|
Status | Outcome of the last search (BnPathSearchStatus). |
Path / PathCount | Polygon sequence, start polygon first. |
PathCost | Total cost of the found path. |
Iterations | Number of expanded polygons โ compare it against your budget. |
BnPathSearchStatus | Meaning |
|---|---|
Found | A path is available in the scratchpad. |
Unreachable | The open set drained without reaching the target. |
BudgetExhausted | maxIterations ran out before the target was expanded. |
InvalidInput | A polygon id is outside the graph. |
CapacityExceeded | The 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:
| Field | Meaning |
|---|---|
PathIndex | Stable integer identity of the slot. |
WaypointCount | Number of valid elements in the buffer. |
Status | None, Pending, Ready, Partial or Failed. |
IsFollowable | True when the count is positive and the status is Ready or Partial. |
BnPathWaypoint is one corridor element:
| Field | Meaning |
|---|---|
Position | Waypoint position on the navigation plane; the last element is the exact target. |
ExitPoint | Portal midpoint used to leave PolyIndex; equals Position for the last element. |
PolyIndex | Polygon that owns this waypoint. |
LinkIndex | Index 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:
- Advances the cursor past every portal the agent has already crossed (
AdvancePathProgress). - Tightens a left/right cone from the agent position through the remaining portals.
- 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
RadiusandBnFunnel.DefaultArrivalRadius(0.05), which keeps a zero-radius agent from jittering on the final point.
Progress tracking
| Field | Meaning |
|---|---|
WaypointIndex | Cursor into the path buffer โ the waypoint the funnel steers toward. |
PathProgress / PathLength | Distance travelled along completed segments and total path length. |
Flags | Following, Arrived and Blocked bits. |
NormalizedProgress | Saturated 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:
- The Free contract is deterministic waypoint following with zero allocation.
- Avoidance needs neighbour data and a shared solver that Free does not allocate or schedule.
- Gameplay that needs separation must provide it at design level โ spaced spawn points, one-way lanes, staggered start times.
IntegrateJob then advances the position branch-free:
Position = math.mad(Velocity, DeltaTime, Position)
๐งฉ Why every stage is job-shaped
| Job | Scheduling | Why |
|---|---|---|
BnPathfindJob | Single-threaded | All agents share one A* scratchpad. |
BnFunnelJob | Parallel | Every agent owns its steering value and buffer. |
BnSteeringStateJob | Parallel | Writes enableable toggles into a ParallelWriter. |
KinematicBypassJob | Parallel | Pure per-agent copy. |
IntegrateJob | Parallel | Pure 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 โ request lifecycle, the search and the funnel call.
- Components & Systems โ the full reference of every job and system.
- Mesh Graph Blob Format โ exact memory layout and sizes.
๐ก 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
| Component | Kind | Fields |
|---|---|---|
BnAgentSteering | IComponentData | Position: float3, Velocity: float3, DesiredVelocity: float3, MaxSpeed: float, Radius: float, PathProgress: float, PathLength: float, WaypointIndex: int, Flags: BnAgentFlags |
BnAgentPath | IComponentData | PathIndex: int, WaypointCount: int, Status: BnPathStatus |
BnPathWaypoint | IBufferElementData | Position: float3, ExitPoint: float3, PolyIndex: int, LinkIndex: int |
BnAgentPathRequest | IComponentData | Start: float3, Target: float3, RequestId: uint, StartPoly: int, TargetPoly: int, Status: BnPathStatus |
BnAgentSteeringActive | IComponentData, IEnableableComponent | none โ chunk enable bit |
BnAgentPathRequestPending | IComponentData, IEnableableComponent | none โ chunk enable bit |
BnBlobMeshGraph | IComponentData | Value: 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);
| Step | Who does it | Result |
|---|---|---|
| Write target + arm toggle | gameplay | BnAgentPathRequest.Status = Pending |
BnPathfindJob | BnPathfindingSystem | snaps Start/Target to polygons, runs A*, fills the buffer |
| Toggle playback | end-of-frame ECB | BnAgentPathRequestPending disabled again |
BnPathStatus.Ready | path slot | corridor is followable |
BnSteeringStateJob | BnSteeringSystem | re-enables BnAgentSteeringActive for followable agents |
BnPathStatus | Meaning |
|---|---|
None | No request issued yet (freshly baked agent). |
Pending | Request armed, not yet resolved. |
Ready | A corridor is available and followable. |
Partial | Reserved for a partial result; Free never produces one. |
Failed | Empty graph, unreachable target, or exhausted budget. Corridor cleared. |
โ ๏ธ
RequestIdis yours alone.BnPathfindJobcopies 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 becomesReady.
๐ง 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:
BnPathScratchpad.Create(polygonCapacity, allocator)allocates once;EnsureCapacity(polygonCount, allocator)grows only when the graph outgrows it.Dispose()must run exactly once.Dispose(JobHandle)releases the arrays after the handle completes โ that is howBnPathfindingSystemretires a resized scratchpad without stalling the main thread.- The scratchpad is not thread-safe while a search mutates it. One search at a time per 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 pair | Use |
|---|---|
DynamicBuffer<BnPathWaypoint> / NativeArray<BnPathWaypoint> | Same semantics; pick what your call site has. |
With / without deltaTime | Without it, deltaTime is 0, so the desired speed is the full MaxSpeed. |
Related statics:
| Method | Returns |
|---|---|
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
| Member | Meaning |
|---|---|
BnAgentFlags.Following | Active path following. |
BnAgentFlags.Arrived | Final waypoint reached; DesiredVelocity is zero. |
BnAgentFlags.Blocked | Reserved for gameplay โ no Free code sets or reads it. |
BnAgentSteering.HasPath | PathLength > 0 && (Flags & Following) != 0. |
BnAgentSteering.NormalizedProgress | PathProgress / 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
| Member | Returns |
|---|---|
PolygonCount, LinkCount, VertexCount | Pool 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 โ every field, job and system contract.
- Mesh Graph Blob Format โ exact layout and byte sizes.
- Limitations & Scope โ what the API does not offer.
๐งฉ 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
| Type | Kind | Fields |
|---|---|---|
BnBlobMeshGraph | IComponentData | Value: 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:
| Component | Type | Written by |
|---|---|---|
BnAgentSteering | IComponentData | BnFunnelJob, KinematicBypassJob, IntegrateJob |
BnAgentPath | IComponentData | BnPathfindJob, BnFunnelJob |
BnPathWaypoint | IBufferElementData | BnPathfindJob |
BnAgentPathRequest | IComponentData | gameplay, BnPathfindJob |
BnAgentSteeringActive | IEnableableComponent | BnSteeringStateJob (via ECB) |
BnAgentPathRequestPending | IEnableableComponent | BnPathfindJob (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.Blockedor 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
| Field | Meaning | Owner |
|---|---|---|
Position | World position. XY is the navigation plane, Z is height. | IntegrateJob |
Velocity | Resolved velocity. | KinematicBypassJob |
DesiredVelocity | Requested velocity from the funnel. | BnFunnel.Solve |
MaxSpeed | Upper bound in units per second. | authored |
Radius | Agent radius โ also the arrival tolerance. | authored |
PathProgress / PathLength | Completed segment length and total length. | BnFunnel |
WaypointIndex | Cursor into the corridor. | BnFunnel |
Flags | Following, Arrived, Blocked. | BnFunnel |
| Member | Semantics |
|---|---|
Idle(float3 position, float maxSpeed, float radius) | Zero velocity, BnAgentFlags.None, no path. |
HasPath | PathLength > 0 && (Flags & Following) != 0. |
NormalizedProgress | PathProgress / PathLength saturated to 0..1, or 0 without a path. |
Both properties are branch-free, read-only and take no allocation.
โ ๏ธ Never write
PathProgress,PathLengthorWaypointIndex. The funnel owns them; overwriting them corrupts the cursor and makes the agent walk backwards along its corridor.
๐ง Also worth knowing
| Type | Fields | Notes |
|---|---|---|
BnPathWaypoint | Position, ExitPoint, PolyIndex, LinkIndex | Create(position, exitPoint, polyIndex, linkIndex) copies the four arguments unchanged. LinkIndex = -1 on the final waypoint. |
BnAgentPathRequest | Start, Target, RequestId, StartPoly, TargetPoly, Status | Create(start, target, requestId) starts as Pending with both polygon ids at -1. |
BnAgentPath | PathIndex, WaypointCount, Status | PathIndex is a stable identity you assign; Free never renumbers it. |
BnPolygon | Center, VertexOffset, VertexCount, NeighborOffset, NeighborCount | Blob struct, read-only after bake. |
BnLinkData | PortalLeft, PortalRight, Target, Cost | Blob struct; Cost <= 0 means "use centre-to-centre distance". |
โ๏ธ Jobs
| Job | Interface | Input | Output |
|---|---|---|---|
BnPathfindJob | IJobChunk | BnAgentPathRequest, BnAgentPath, BnPathWaypoint buffer, enabled BnAgentPathRequestPending, graph singleton | BnAgentPathRequest, BnAgentPath, waypoint buffer, SetComponentEnabled<BnAgentPathRequestPending>(false) |
BnFunnelJob | IJobChunk | BnAgentSteering, BnAgentPath, waypoint buffer, BnAgentSteeringActive, graph singleton | BnAgentSteering |
BnSteeringStateJob | IJobChunk | BnAgentPath, BnAgentSteeringActive | SetComponentEnabled<BnAgentSteeringActive> commands |
KinematicBypassJob | IJobChunk | BnAgentSteering (active query) | BnAgentSteering.Velocity |
IntegrateJob | IJobChunk | BnAgentSteering (active query) | BnAgentSteering.Position |
Behavioural details that are easy to miss:
BnPathfindJobexpands one flat A* per pending agent into the shared scratchpad, so it schedules single-threaded. Required toggle state is enforced by the query (BnAgentPathRequestPendingenabled), and the job records the toggle-off command rather than writing enable bits directly.BnFunnelJobruns on a query built withEntityQueryOptions.IgnoreComponentEnabledState, so disabled agents are still visited and a freshly assigned path can reactivate them. It callsBnFunnel.Solveon a local copy and does not write the path slot or the buffer back.BnSteeringStateJobderivesIsSteerablefromBnAgentPath.IsFollowableand records the toggle in aParallelWriter, so it can run in parallel with the funnel job.KinematicBypassJobandIntegrateJobrun on the active query and skip disabled agents throughChunkEntityEnumerator.IntegrateJobis branch-free and usesmath.mad.
๐๏ธ Systems
| System | Group | Fields | Owns |
|---|---|---|---|
BnPathfindingSystem | SimulationSystemGroup | MaxIterations (default DefaultMaxIterations = 4096), properties HasScratchpad, ScratchpadCapacity | one persistent BnPathScratchpad |
BnSteeringSystem | SimulationSystemGroup, [UpdateAfter(BnPathfindingSystem)], [UpdateBefore(EndSimulationEntityCommandBufferSystem)] | none | no native memory |
System order
| Order | Who | Work |
|---|---|---|
| 1 | your tuning system (InitializationSystemGroup) | one-shot field assignment |
| 2 | your request system (SimulationSystemGroup, before BnPathfindingSystem) | write target, arm the request |
| 3 | BnPathfindingSystem | flat A* and corridor write |
| 4 | BnSteeringSystem | funnel โ bypass โ integrate |
| 5 | EndSimulationEntityCommandBufferSystem | single 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
| Rule | Why |
|---|---|
Never call Complete() on the pathfinding or steering handles from OnUpdate | Serializes the frame; read the components on a later frame instead. |
Read and write components through chunk arrays, never per-entity GetComponentData in a loop | Each per-entity call is a random memory access into archetype storage. |
Let the systems own the EntityCommandBuffer playback | One playback at frame end keeps toggles consistent within a frame. |
Keep exactly one BnBlobMeshGraph singleton | Both systems early-out on zero or multiple matches. |
| Keep one dominant agent archetype | Denser chunks, better L1/L2 hit ratio during iteration. |
See also
- Runtime API โ the public calls and their signatures.
- Mesh Graph Blob Format โ the memory layout these jobs read.
- Performance & Tuning โ budget, speed and Burst settings.
๐ฆ 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
| Struct | Fields | Bytes |
|---|---|---|
BnPolygon | Center: float2 (8) + VertexOffset: int (4) + VertexCount: int (4) + NeighborOffset: int (4) + NeighborCount: int (4) | 24 |
BnLinkData | PortalLeft: float2 (8) + PortalRight: float2 (8) + Target: int (4) + Cost: float (4) | 24 |
| vertex | float2 | 8 |
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.
| Pool | Size for CellsX ร CellsY |
|---|---|
Polygons | X * Y |
Vertices | 4 * X * Y |
Links | 2 * ((X-1) * Y + X * (Y-1)) |
NeighborPolygons | same as Links |
PolyLinkOffsets / PolyLinkCounts | X * 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
| Pool | Count | Bytes |
|---|---|---|
Polygons | 16 | 384 |
Vertices | 64 | 512 |
Links | 24 | 576 |
NeighborPolygons | 24 | 96 |
PolyLinkOffsets | 16 | 64 |
PolyLinkCounts | 16 | 64 |
| Total (payload) | โ 1.7 KB |
Example: 100 ร 100 grid, CellSize = 1
| Pool | Count | Bytes |
|---|---|---|
Polygons | 10 000 | โ 234 KB |
Vertices | 40 000 | โ 313 KB |
Links | 39 600 | โ 928 KB |
NeighborPolygons | 39 600 | โ 155 KB |
PolyLinkOffsets + PolyLinkCounts | 10 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
Verticesby ~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
| Rule | Consequence of breaking it |
|---|---|
The blob never changes after CreateBlobAssetReference | Jobs read it without a job dependency of their own. |
Exactly one BnBlobMeshGraph per world | Both systems early-out on zero or multiple matches โ the pipeline silently stops. |
| The creator disposes the blob | Authoring-baked blobs are owned by the baking system; BuildGraph blobs are yours to Dispose(). |
| Never swap the blob while searches are in flight | Existing 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:
- Compose from grids. Bake several
BnMeshAuthoringentities โ each produces its own graph, but only one may be the singleton, so grids are usually combined into a single level grid instead. - Write your own builder. Build a
BnMeshGraphBlobwithBlobBuilder, keeping the invariants below, then assign it to aBnBlobMeshGraphentity.
Invariants for a hand-built blob
| Invariant | Check |
|---|---|
Every BnPolygon is convex | The funnel assumes convex portals between neighbours. |
Target of every link is a valid polygon id | 0 <= Target < PolygonCount. |
PolyLinkOffsets[p] + PolyLinkCounts[p] <= LinkCount | No slice may overrun the link pool. |
VertexOffset + VertexCount <= VertexCount (the pool length) | Vertex slices must stay in the pool. |
NeighborOffset + NeighborCount <= NeighborPolygons.Length | Neighbour slices must stay in the pool. |
| Link order matches neighbour order | GetNeighbor(p, i) should be the polygon reached by GetPolyLink(p, i). |
PortalLeft/PortalRight are the shared edge | The funnel reads portal midpoints, not polygon centres. |
A non-positive Cost is intentional | It 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:
| Array | Length | Indexed by |
|---|---|---|
GScore, CameFrom, HeapSlots, Closed, Path | Capacity | polygon id |
HeapPolygons, HeapKeys | Capacity + 1 | heap slot (extra slot allows a speculative push without a bounds check) |
VisitStamp | Capacity + 1 | polygon 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
- How It Works โ how the pools are consumed by A* and the funnel.
- Components & Systems โ who schedules what against this blob.
- Performance & Tuning โ sizing the scratchpad and the budget.
๐๏ธ 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
| Stage | Complexity | Threading |
|---|---|---|
| Polygon resolve + flat A* | O(expanded polygons) per request | single-threaded (one shared scratchpad) |
| Corridor write | O(corridor length) | same job |
| Funnel + progress | O(corridor length) per agent | parallel |
| Bypass | O(1) per agent | parallel |
| Integrate | O(1) per agent | parallel |
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.
| Value | Effect |
|---|---|
| Too low | Long paths end as BnPathStatus.Failed and the corridor is cleared. |
| 4096 (default) | Covers most levels up to a few thousand polygons. |
| Larger | Tolerates 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
| Allocation | Lifetime | Size |
|---|---|---|
| Graph blob | level | see Mesh Graph Blob Format |
| A* scratchpad (system-owned) | level | โ 29 bytes per polygon + 12 bytes of spare slots |
| Waypoint buffers | per agent | 16 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
| Field | Effect |
|---|---|
MaxSpeed | Upper bound of DesiredVelocity and Velocity, units per second. |
Radius | Agent 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
MaxSpeedin one frame. For smoother motion, lowerMaxSpeedor 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 setting | Development | Ship |
|---|---|---|
| Jobs โ Burst โ Enable Compilation | on | on |
| Jobs โ Burst โ Synchronous Compilation | only when debugging Burst code | off |
| Jobs โ Safety Checks | on | off in release |
| Jobs โ Leak Detection | on | on in development builds |
Runtime rules that keep the pipeline valid:
- Do not call
Completeon the pathfinding or steering handles from gameplay; read state on a later frame instead. - Do not write the system-owned
BnPathScratchpad. - Keep one dominant agent archetype and one
BnBlobMeshGraphsingleton. - Do not spawn or destroy agents per frame; batch structural changes into a command buffer.
๐ฌ Measuring instead of guessing
| Question | Where 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:
- Reduce graph size. Bigger
CellSizemeans fewer, larger polygons โ the same level with a quarter of the polygons runs roughly four times cheaper per search. - Request less often. Paths are static; re-request only on a new destination, not every frame.
- Raise the budget only after measuring.
MaxIterationsdoes not make searches faster โ it makes more of them succeed. - 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.
- Replace the pathfinding stage if you need hierarchical search or filtered long routes. That is an architecture change, not a setting.
See also
- Components & Systems โ which job owns which field.
- Mesh Graph Blob Format โ exact memory numbers.
- Troubleshooting & FAQ โ when tuning does not help.
โ ๏ธ 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 size | Behaviour |
|---|---|
| Tens to a few thousand polygons | The default 4096-expansion budget covers typical paths. |
| Several thousand polygons | Raise MaxIterations or long routes may fail. |
| Tens of thousands of polygons | Each 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:
- Agents on crossing paths can overlap.
- A stopped agent does not block or deflect a moving agent.
- Dense groups do not separate, queue or spread out around corners.
- Throughput through a narrow portal is not regulated.
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.
- Moving a wall, crate or vehicle does not change the graph or the agent paths.
- An agent keeps following its corridor even if something now occupies it.
- Adding or removing blocked regions requires rebuilding the blob and replacing the graph singleton.
- There is no built-in push-out when an agent overlaps a static or moving blocker.
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.
- You cannot close a doorway for one agent and leave it open for another.
- You cannot route around a locked area through the Free systems.
- Access control must be enforced by gameplay before a request is issued, and the graph must not contain the forbidden region.
- A closed door is a graph change โ a rebake and a repath, not a per-link flag.
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:
- Exactly one
BnBlobMeshGraphsingleton. Both systems skip their work when there is none โ and when there is more than one. - A graph must exist before agents request paths:
BnPathfindingSystemreturns early whilegraph.Valueis not created. - Topology is fixed for the lifetime of the blob. Replacing the blob while searches are in flight is not supported by the Free systems.
๐ 2.5-D navigation
Paths and steering are solved on XZ only:
- No ramp or stair following, and the pipeline never modifies agent Y โ vertical movement is gameplay's job.
- A multi-floor level flattens into one plane, so a "vertical" route is a straight XZ shortcut.
- Polygons must be convex, and
BnMeshAuthoringproduces axis-aligned squares only. - A spawn or destination far outside the mesh resolves to the nearest polygon rather than failing, which can look like a path that starts in the wrong place.
๐งฉ Choosing the right tool
| Your level needs | Free | Notes |
|---|---|---|
| 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:
- Replace or wrap the steering system when agents must stay apart in crowds, queues or narrow corridors.
- Replace the pathfinding job when the flat search is the frame-time bottleneck, long routes hit
MaxIterations, or paths need a different filter. - Rebuild and swap the graph blob when obstacles move or the level changes โ never while searches are in flight.
- Enforce doors and areas before a request is issued, or write a filtered search job around
BnAStar.FindPath.
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
- How It Works โ the architecture these limits come from.
- Performance & Tuning โ the knobs that do exist.
- Troubleshooting & FAQ โ symptoms and their causes.
๐ Troubleshooting & FAQ
๐ Agent does not move
Work through this list in order โ it covers every cause we know of.
| # | Check | Fix |
|---|---|---|
| 1 | Is there exactly one BnBlobMeshGraph with Value.IsCreated? | Bake the graph in a SubScene, or call BnMeshAuthoringBaker.BuildGraph once at startup. |
| 2 | Does the agent carry all six components? | Use BnAgentAuthoring or BnAgentComponents.CreateAgentArchetype. |
| 3 | Is BnAgentPathRequestPending enabled? | Enable it after writing a target โ a freshly baked agent has it off by design. |
| 4 | Did you write a Target different from Start? | The baker sets both to the spawn position. |
| 5 | Are BnPathfindingSystem and BnSteeringSystem present and enabled? | Check Window โ Entities โ Systems; in a custom world, create both inside SimulationSystemGroup. |
| 6 | Is BnAgentSteeringActive enabled? | BnSteeringStateJob turns it on when a path becomes followable; a manual false keeps the agent frozen. |
| 7 | Is 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:
| Cause | Symptom | Fix |
|---|---|---|
| No route between the resolved polygons | StartPoly/TargetPoly are valid but disconnected | Check the graph actually connects those regions; a grid graph with CellsX = 1 cannot go sideways. |
| Budget exhausted | scratch.Iterations == MaxIterations | Raise BnPathfindingSystem.MaxIterations. |
| Empty graph | PolygonCount == 0, so both snaps return -1 | The 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
| Cause | Fix |
|---|---|
| Z was used as the navigation plane | Pathfinding is XZ only: put the level on XZ and use Y for height. |
| The graph sits somewhere else than the level | Origin and CellSize of BnMeshAuthoring must match the visual layout. |
| Corridor waypoints were edited by gameplay | Never 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
| Symptom | Fix |
|---|---|
| No sample in the Samples tab | Confirm the package version is 1.1.0 and that package.json lists the sample; refresh Package Manager. |
| Missing script references | Keep the generated Scripts folder and its .asmdef intact โ it references SnivelerCode.BurstNav.Runtime. |
| Scene opens with missing scripts | Delete Assets/Samples/BurstNav Free, reimport from the Samples tab, reopen the scene. |
Samples~ is not under Assets | Expected โ the folder is hidden by design until imported. |
| Gizmos are invisible | Select 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?
- Re-run the two samples without modification โ they exercise the exact pipeline described here.
- Compare your setup against Quick Start step by step.
- Read Components & Systems to confirm who is supposed to write each field.