public sealed class Sandbox.Navigation.NavMesh
Navigation Mesh - allowing AI to navigate a world
Related Guides
Broader workflow and conceptual references connected to this API.
We implement Recast Navigation in s&box, the industry standard for navmesh generation and navigation agents. It's used in Unreal, Unity and Godot. So if it seems familiar, that's why.
Core gameplay systems — input, navigation, terrain, and more.
A NavMesh Agent will move from position to position on the NavMesh, automatically. It features crowd control features, so they will try to avoid bumping into each other if possible.
NavNesh Areas can affect NavNesh generation and agent behavior/pathing. The NavMeshArea component is used to define the location, shape and type of an area.
Areas can be used to block of certain areas of the NavNesh both in editor and at runtime. This will completely omit an area from navmesh generation.
As you play with developing in s&box, you will notice some things are weird, missing, or suck. We are aware.
Methods
Showing 19 methods
public static void BakeNavMesh()
public Sandbox.Navigation.NavMeshPath CalculatePath(Sandbox.Navigation.CalculatePathRequest request)
Computes a navigation path between the specified start and target positions on the navmesh. Uses the same pathfinding algorithm as `Sandbox.NavMeshAgent`, taking agent configuration into account if provided. The result is suitable for direct use with `Sandbox.NavMeshAgent.SetPath(Sandbox.Navigation.NavMeshPath)`. If a complete path cannot be found, the result may indicate an incomplete or failed path.
public virtual sealed void Dispose()
public System.Threading.Tasks.Task`1<bool> Generate(Sandbox.PhysicsWorld world)
public System.Threading.Tasks.Task GenerateTile(Sandbox.PhysicsWorld world, Vector3 worldPosition)
Generates or regenerates the navmesh tile at the given world position. This function is thread safe but can only be called from the main thread.
Note
While most of the generation happens in parallel, this function also requires some time on the main thread. If you need to update many tiles, consider spreading the updates accross multiple frames.
public System.Threading.Tasks.Task GenerateTiles(Sandbox.PhysicsWorld world, BBox bounds)
Generates or regenerates the navmesh tiles overlapping with the given bounds. This function is thread safe but can only be called from the main thread.
Note
While most of the generation happens in parallel, this function also requires some time on the main thread. If you need to update many tiles, consider spreading the updates accross multiple frames.
public System.Collections.Generic.List`1<Vector3> GetSimplePath(Vector3 from, Vector3 to)Obsolete
Obsolete: Use CalculatePath instead
public void RequestTileGeneration(Vector3 worldPosition)
Queues the navmesh tile at the given world position for incremental generation over subsequent frames. Fire-and-forget alternative to `Sandbox.Navigation.NavMesh.GenerateTile(Sandbox.PhysicsWorld,Vector3)`.
public void RequestTilesGeneration(BBox bounds)
Queues all navmesh tiles overlapping with the given bounds for incremental generation over subsequent frames. Fire-and-forget alternative to `Sandbox.Navigation.NavMesh.GenerateTiles(Sandbox.PhysicsWorld,BBox)`.
public void SetDirty()
Set the navgiation a dirty, so it will rebuild over the next few frames. If you need an immediate rebuild, call `Sandbox.Navigation.NavMesh.Generate(Sandbox.PhysicsWorld)` instead.
public void UnloadTile(Vector3 worldPosition)
Removes the navmesh tile at the given world position.
public void UnloadTiles(BBox bounds)
Removes all navmesh tiles overlapping with the given bounds.
No results match this filter.
Properties
Showing 16 properties
public float Sandbox.Navigation.NavMesh.AgentHeight { get; set; }
Height of the agent
public float Sandbox.Navigation.NavMesh.AgentMaxSlope { get; set; }
The maximum slope an agent can walk up (in degrees)
public float Sandbox.Navigation.NavMesh.AgentRadius { get; set; }
The radius of the agent. This will change how much gap is left on the edges of surfaces, so they don't clip into walls.
public float Sandbox.Navigation.NavMesh.AgentStepSize { get; set; }
The maximum height an agent can climb (step)
public BBox Sandbox.Navigation.NavMesh.Bounds { get; set; }
The bounds to generate the navmesh within. Won't take effect until regenerated or reloaded.
public bool Sandbox.Navigation.NavMesh.CustomBounds { get; set; }
By Default , the navmesh will calculate bounds based on the world geometry, but if you want to override that, you can set custom bounds here.
public bool Sandbox.Navigation.NavMesh.DeferGeneration { get; set; }
Skip tile generation during scene load. Tiles can then be generated on demand via `Sandbox.Navigation.NavMesh.GenerateTile(Sandbox.PhysicsWorld,Vector3)`, `Sandbox.Navigation.NavMesh.RequestTileGeneration(Vector3)`, etc.
public bool Sandbox.Navigation.NavMesh.DrawMesh { get; set; }
Draw the navigation mesh in the editor
public bool Sandbox.Navigation.NavMesh.EditorAutoUpdate { get; set; }
Constantly update the navigation mesh in the editor
public Sandbox.TagSet Sandbox.Navigation.NavMesh.ExcludedBodies { get; set; }
Don't include these bodies in the generation
public Sandbox.TagSet Sandbox.Navigation.NavMesh.IncludedBodies { get; set; }
If any, we'll only include bodies with this tag
public bool Sandbox.Navigation.NavMesh.IncludeKeyframedBodies { get; set; }
Should the generator include keyframed bodies
public bool Sandbox.Navigation.NavMesh.IncludeStaticBodies { get; set; }
Should the generator include static bodies
public bool Sandbox.Navigation.NavMesh.IsDirty { get; set; }
The navigation mesh is dirty and needs a complete rebuild
public bool Sandbox.Navigation.NavMesh.IsEnabled { get; set; }
Determines wether the navigation mesh is enabled and should be generated
public bool Sandbox.Navigation.NavMesh.IsGenerating { get; set; }
The navigation mesh is generating
No results match this filter.
Metadata
| Field | Value |
|---|---|
| Namespace | Sandbox.Navigation |
| Type | class |
| Assembly | Sandbox.Engine |
| Doc ID | T:Sandbox.Navigation.NavMesh |