NavMesh
public sealed class NavMesh Navigation Mesh - allowing AI to navigate a world
Properties
| Name | Type | Description |
|---|---|---|
IsEnabled | Boolean | Determines wether the navigation mesh is enabled and should be generated |
IsGenerating | Boolean | The navigation mesh is generating |
IsDirty | Boolean | The navigation mesh is dirty and needs a complete rebuild |
IncludeStaticBodies | Boolean | Should the generator include static bodies |
IncludeKeyframedBodies | Boolean | Should the generator include keyframed bodies |
ExcludedBodies | TagSet | Don't include these bodies in the generation |
IncludedBodies | TagSet | If any, we'll only include bodies with this tag |
CustomBounds | Boolean | 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. |
Bounds | BBox | The bounds to generate the navmesh within. Won't take effect until regenerated or reloaded. |
EditorAutoUpdate | Boolean | Constantly update the navigation mesh in the editor |
DrawMesh | Boolean | Draw the navigation mesh in the editor |
AgentHeight | Single | Height of the agent |
AgentRadius | Single | 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. |
AgentStepSize | Single | The maximum height an agent can climb (step) |
AgentMaxSlope | Single | The maximum slope an agent can walk up (in degrees) |
Methods
static Void BakeNavMesh() virtual Void Dispose() Void SetDirty() Set the navgiation a dirty, so it will rebuild over the next few frames. If you need an immediate rebuild, call PhysicsWorld) instead.
Task<Boolean> Generate(PhysicsWorld world) Task GenerateTile(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.
Task GenerateTiles(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.
NavMeshPath CalculatePath(CalculatePathRequest request) Computes a navigation path between the specified start and target positions on the navmesh. Uses the same pathfinding algorithm as NavMeshAgent, taking agent configuration into account if provided. The result is suitable for direct use with NavMeshPath). If a complete path cannot be found, the result may indicate an incomplete or failed path.
Vector3? GetRandomPoint() Vector3? GetRandomPoint(BBox box) Get a random point on the navmesh, within the bounding box. This will return null if it can't find a point on the navmesh in a few tries. Returning false doesn't mean it's impossible, our algorithm here isn't the best.
Vector3? GetRandomPoint(Vector3 position, Single radius) Get a random point on the navmesh, within the sphere. This will return null if it can't find a point on the navmesh in a few tries. Returning false doesn't mean it's impossible, our algorithm here isn't the best.
Vector3? GetClosestPoint(BBox box) Vector3? GetClosestPoint(Vector3 position, Single radius = 1024) Vector3? GetClosestEdge(BBox box) Vector3? GetClosestEdge(Vector3 position, Single radius = 1024)