s&box docs
API ReferenceSandbox.Navigation

public sealed class Sandbox.Navigation.NavMesh

Navigation Mesh - allowing AI to navigate a world

Broader workflow and conceptual references connected to this API.

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.

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

Metadata

FieldValue
NamespaceSandbox.Navigation
Typeclass
AssemblySandbox.Engine
Doc IDT:Sandbox.Navigation.NavMesh

On this page

Methodspublic static System.Void BakeNavMesh()public Sandbox.Navigation.NavMeshPath CalculatePath(Sandbox.Navigation.CalculatePathRequest request)public virtual sealed System.Void Dispose()public System.Threading.Tasks.Task`1<System.Boolean> Generate(Sandbox.PhysicsWorld world)public System.Threading.Tasks.Task GenerateTile(Sandbox.PhysicsWorld world, Vector3 worldPosition)public System.Threading.Tasks.Task GenerateTiles(Sandbox.PhysicsWorld world, BBox bounds)public System.Nullable`1<Vector3> GetClosestEdge(BBox box)public System.Nullable`1<Vector3> GetClosestEdge(Vector3 position, System.Single radius = 1024)public System.Nullable`1<Vector3> GetClosestPoint(BBox box)public System.Nullable`1<Vector3> GetClosestPoint(Vector3 position, System.Single radius = 1024)public System.Nullable`1<Vector3> GetRandomPoint()public System.Nullable`1<Vector3> GetRandomPoint(BBox box)public System.Nullable`1<Vector3> GetRandomPoint(Vector3 position, System.Single radius)public System.Collections.Generic.List`1<Vector3> GetSimplePath(Vector3 from, Vector3 to)public System.Void RequestTileGeneration(Vector3 worldPosition)public System.Void RequestTilesGeneration(BBox bounds)public System.Void SetDirty()public System.Void UnloadTile(Vector3 worldPosition)public System.Void UnloadTiles(BBox bounds)Propertiespublic System.Single Sandbox.Navigation.NavMesh.AgentHeight { get; set; }public System.Single Sandbox.Navigation.NavMesh.AgentMaxSlope { get; set; }public System.Single Sandbox.Navigation.NavMesh.AgentRadius { get; set; }public System.Single Sandbox.Navigation.NavMesh.AgentStepSize { get; set; }public BBox Sandbox.Navigation.NavMesh.Bounds { get; set; }public System.Boolean Sandbox.Navigation.NavMesh.CustomBounds { get; set; }public System.Boolean Sandbox.Navigation.NavMesh.DeferGeneration { get; set; }public System.Boolean Sandbox.Navigation.NavMesh.DrawMesh { get; set; }public System.Boolean Sandbox.Navigation.NavMesh.EditorAutoUpdate { get; set; }public Sandbox.TagSet Sandbox.Navigation.NavMesh.ExcludedBodies { get; set; }public Sandbox.TagSet Sandbox.Navigation.NavMesh.IncludedBodies { get; set; }public System.Boolean Sandbox.Navigation.NavMesh.IncludeKeyframedBodies { get; set; }public System.Boolean Sandbox.Navigation.NavMesh.IncludeStaticBodies { get; set; }public System.Boolean Sandbox.Navigation.NavMesh.IsDirty { get; set; }public System.Boolean Sandbox.Navigation.NavMesh.IsEnabled { get; set; }public System.Boolean Sandbox.Navigation.NavMesh.IsGenerating { get; set; }Metadata