API ReferenceSandbox.Navigation

NavMeshclass

Navigation Mesh - allowing AI to navigate a world

objectNavMesh
Namespace
Sandbox.Navigation
Assembly
Sandbox.Engine
Declaration
public sealed class Sandbox.Navigation.NavMesh

Methods19

Showing 19 methods

public static void BakeNavMesh()PUBLICSTATIC

Returns:void

public Sandbox.Navigation.NavMeshPath CalculatePath(Sandbox.Navigation.CalculatePathRequest request)PUBLIC

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.

ParameterTypeDescription
requestCalculatePathRequest
Returns:NavMeshPath

public virtual sealed void Dispose()PUBLICVIRTUAL

Returns:void

public System.Threading.Tasks.Task`1<bool> Generate(Sandbox.PhysicsWorld world)PUBLIC

ParameterTypeDescription
worldPhysicsWorld
Returns:Task<bool>

public System.Threading.Tasks.Task GenerateTile(Sandbox.PhysicsWorld world, Vector3 worldPosition)PUBLIC

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.

ParameterTypeDescription
worldPhysicsWorld
worldPositionVector3
Returns:Task

public System.Threading.Tasks.Task GenerateTiles(Sandbox.PhysicsWorld world, BBox bounds)PUBLIC

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.

ParameterTypeDescription
worldPhysicsWorld
boundsBBox
Returns:Task

public System.Collections.Generic.List`1<Vector3> GetSimplePath(Vector3 from, Vector3 to)PUBLICOBSOLETE

Obsolete: Use CalculatePath instead

ParameterTypeDescription
fromVector3
toVector3
Returns:List<Vector3>

public void RequestTileGeneration(Vector3 worldPosition)PUBLIC

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)`.

ParameterTypeDescription
worldPositionVector3
Returns:void

public void RequestTilesGeneration(BBox bounds)PUBLIC

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)`.

ParameterTypeDescription
boundsBBox
Returns:void

public void SetDirty()PUBLIC

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.

Returns:void

public void UnloadTile(Vector3 worldPosition)PUBLIC

Removes the navmesh tile at the given world position.

ParameterTypeDescription
worldPositionVector3
Returns:void

public void UnloadTiles(BBox bounds)PUBLIC

Removes all navmesh tiles overlapping with the given bounds.

ParameterTypeDescription
boundsBBox
Returns:void

Properties16

Showing 16 properties

public float Sandbox.Navigation.NavMesh.AgentHeight { get; set; }PUBLICGETSET

Height of the agent

Returns:float

public float Sandbox.Navigation.NavMesh.AgentMaxSlope { get; set; }PUBLICGETSET

The maximum slope an agent can walk up (in degrees)

Returns:float

public float Sandbox.Navigation.NavMesh.AgentRadius { get; set; }PUBLICGETSET

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.

Returns:float

public float Sandbox.Navigation.NavMesh.AgentStepSize { get; set; }PUBLICGETSET

The maximum height an agent can climb (step)

Returns:float

public BBox Sandbox.Navigation.NavMesh.Bounds { get; set; }PUBLICGETSET

The bounds to generate the navmesh within. Won't take effect until regenerated or reloaded.

Returns:BBox

public bool Sandbox.Navigation.NavMesh.CustomBounds { get; set; }PUBLICGETSET

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.

Returns:bool

public bool Sandbox.Navigation.NavMesh.DeferGeneration { get; set; }PUBLICGETSET

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.

Returns:bool

public bool Sandbox.Navigation.NavMesh.DrawMesh { get; set; }PUBLICGETSET

Draw the navigation mesh in the editor

Returns:bool

public bool Sandbox.Navigation.NavMesh.EditorAutoUpdate { get; set; }PUBLICGETSETPER-FRAME

Constantly update the navigation mesh in the editor

Returns:bool

public Sandbox.TagSet Sandbox.Navigation.NavMesh.ExcludedBodies { get; set; }PUBLICGETSET

Don't include these bodies in the generation

Returns:TagSet

public Sandbox.TagSet Sandbox.Navigation.NavMesh.IncludedBodies { get; set; }PUBLICGETSET

If any, we'll only include bodies with this tag

Returns:TagSet

public bool Sandbox.Navigation.NavMesh.IncludeKeyframedBodies { get; set; }PUBLICGETSET

Should the generator include keyframed bodies

Returns:bool

public bool Sandbox.Navigation.NavMesh.IncludeStaticBodies { get; set; }PUBLICGETSET

Should the generator include static bodies

Returns:bool

public bool Sandbox.Navigation.NavMesh.IsDirty { get; set; }PUBLICGETSET

The navigation mesh is dirty and needs a complete rebuild

Returns:bool

public bool Sandbox.Navigation.NavMesh.IsEnabled { get; set; }PUBLICGETSET

Determines wether the navigation mesh is enabled and should be generated

Returns:bool

public bool Sandbox.Navigation.NavMesh.IsGenerating { get; set; }PUBLICGETSET

The navigation mesh is generating

Returns:bool

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