Common API Examples
Runtime Navmesh Baker – Common API Examples
This page shows the most common tasks you’ll perform in game code when working with the BakerCoordinator.
Getting a Coordinator
// Recommended: reference the one you’ve placed in your scene
var coord = BakerCoordinator.Active;
// Fallback: search the scene (slower, but safe if only one exists)
var coord = FindObjectOfType<BakerCoordinator>();If you expect there might not be one in the scene, you can call BakerCoordinator.Ensure() to auto-create one.
Setting the Target to Follow
Tell the baker which object (usually your player or camera) should act as the bake center:
coord.SetCenterTarget(player.transform);By default this immediately triggers a bake.
You can disable the immediate rebake:
coord.SetCenterTarget(player.transform, rebakeNow: false);Starting Baking Manually
If autoStart is off (or you want to trigger manually):
This will:
Bake around the current target (Continuous / Combined modes).
Bake the active grid cells (Grid mode).
Aliases:
Marking Surfaces Dirty
If you modify geometry at runtime:
Optional overloads let you pass bounds, agent type, or priority.
Checking Bake Status
Example: Spawning a Player Dynamically
Quick Reference
SetCenterTarget(Transform, bool)→ set follow target.StartBaking()/BakeNow()→ enqueue an initial bake.BakeAllNow()→ bake all registered surfaces.RegisterSurface()/UnregisterSurface()→ manage surfaces.MarkSurfaceDirty()→ force rebake of a surface region.QueuedCount/InFlightCount→ runtime stats.
Last updated