Navmesh¶
Classes¶
- NavMesh : NativeComponent¶
Represents a navigation mesh. Use ‘Bake’ and ‘Clear’ in this component to bake navmesh. Baking collects all static (non-moving, non-sensor) Collider components in the child nodes under this node to construct navmesh.
- NavMesh.bakeAsync(cb: lambda<(result:BakeResult):void>)¶
Bakes a navigation mesh from the static Collider geometry under this NavMesh node (dynamic, kinematic and sensor bodies are skipped), using the agent parameters (radius, height, climb, slope, cell size) on this component. Replaces any previous bake of the same volume; peer volumes are left intact. Calls the provided block once the bake is finished; treat the bake as asynchronous and do not rely on the block running within this call. The outcome is BakeResult.Baked when a navmesh was produced, BakeResult.Empty when the bake ran but produced no walkable navmesh (no static Collider geometry under the node, or none of it was walkable) and cleared any previous navmesh of the volume, or BakeResult.Failed when the bake could not run at all (the reason is logged).
- Arguments:
cb : lambda<(result: BakeResult):void> - the lambda to call with the BakeResult outcome when the bake is finished
- NavMesh.findPath(req: NavPathQuery; blk: block<(path:array<float3>):void>): PathResult¶
Searches the navmesh baked with this component’s agent profile for a walkable route, and if one was found, calls the provided block with the waypoints in order (from..to).
- Arguments:
req : NavPathQuery - the pathfinding request
blk : block<(path:array<float3>):void> - the block to call with the waypoint array (not called on PathResult.NoPath)
- Returns:
PathResult - PathResult.Full for a complete route, PathResult.Partial when the goal is
unreachable (or req.maxPathPoints was hit) and the path stops at the closest reachable point, PathResult.NoPath when nothing walkable was found for this profile
- NavMesh.trace(req: NavRayCast; blk: block<(hit:NavTraceHit):void>): NavMeshTraceResult¶
Casts a walkability ray along this profile’s navmesh surface from req.from toward req.to, and if a wall blocks the way, calls the provided block for the resulting hit.
- Arguments:
req : NavRayCast - the raycast request
blk : block<(hit: NavTraceHit):void> - the block to call with the wall hit (called only on NavMeshTraceResult.Blocked)
- Returns:
NavMeshTraceResult - NavMeshTraceResult.Reached when the straight line is walkable, NavMeshTraceResult.Blocked
when a wall is in the way, NavMeshTraceResult.NotOnNavMesh when req.from is not on the navmesh
- NavMesh.projectPoint(req: NavPointQuery; blk: block<(projected:float3):void>): bool¶
Projects a world position onto the nearest point of this profile’s navmesh (height follows the navmesh surface), and if the position is close enough, calls the provided block with the result.
- Arguments:
req : NavPointQuery - the projection request
blk : block<(projected:float3):void> - the block to call with the projected point (not called when nothing is close enough)
- Returns:
bool - true when req.pos is close enough to the navmesh
- NavMesh.distanceToWall(req: NavWallQuery; blk: block<(hit:NavWallHit):void>): float¶
Measures the distance from a position (projected onto this profile’s navmesh) to the nearest navmesh wall within req.maxRadius, and if a wall was found, calls the provided block for it.
- Arguments:
req : NavWallQuery - the distance-to-wall request
blk : block<(hit: NavWallHit):void> - the block to call with the nearest wall (not called when no wall is within the radius)
- Returns:
float - the distance to the nearest wall, req.maxRadius when no wall is that close, or a
negative value when req.pos is not on the navmesh
- NavMesh.randomPointsAroundCircle(req: NavCircleQuery; blk: block<(points:array<float3>):void>): int¶
Generates up to req.count random walkable positions reachable from req.center within req.radius on this profile’s navmesh, and if any were produced, calls the provided block with the array of points.
- Arguments:
req : NavCircleQuery - the random-points request
blk : block<(points:array<float3>):void> - the block to call with the generated points (not called when none were produced)
- Returns:
int - the number of points produced (0 when req.center is not on the navmesh)
- NavMesh.randomPoint(seed: int; blk: block<(point:float3):void>): bool¶
Picks a random walkable position anywhere on this profile’s navmesh (polygons weighted by area), and if one was produced, calls the provided block with it.
- Arguments:
seed : int - random seed; 0 is non-deterministic (each call differs), any nonzero seed reproduces the same point
blk : block<(point:float3):void> - the block to call with the random position (not called when nothing is baked)
- Returns:
bool - true when a point was produced
- Properties:
- NavMesh.agentRadius: float¶
- NavMesh.agentRadius =(value: float)¶
Radius of the agent capsule.
- Arguments:
value : float
- NavMesh.agentHeight: float¶
- NavMesh.agentHeight =(value: float)¶
Height of the agent capsule.
- Arguments:
value : float
- NavMesh.agentMaxClimb: float¶
- NavMesh.agentMaxClimb =(value: float)¶
Maximum height step the agent can climb.
- Arguments:
value : float
- NavMesh.agentMaxSlope: float¶
- NavMesh.agentMaxSlope =(value: float)¶
Maximum walkable slope angle in degrees.
- Arguments:
value : float
- NavMesh.cellSize: float¶
- NavMesh.cellSize =(value: float)¶
Voxel cell size (XZ plane) for the navmesh bake.
- Arguments:
value : float
- NavMesh.cellHeight: float¶
- NavMesh.cellHeight =(value: float)¶
Voxel cell height (Y axis) for the navmesh bake.
- Arguments:
value : float
- NavMesh.isBaked: bool¶
Whether this volume currently has a baked navmesh.
Structures¶
- NavPathQuery¶
Represents a navmesh pathfinding request.
- Fields:
from : float3 - The world-space start position
to : float3 - The world-space target position
ext : float3 = float3(0f,0f,0f) - Half-extents of the box used to project from/to onto the navmesh, resolved per axis: a zero component takes the profile-derived default (so float3(0) is fully automatic, float3(0, 5, 0) widens only Y)
maxPathPoints : int = 0 - Cap on the number of waypoints (0 = no cap); hitting the cap yields PathResult.Partial. Use to keep a query inside a frame budget
- NavRayCast¶
Represents a navmesh walkability raycast request: whether an agent could walk in a straight line, not what a 3D ray would hit.
- Fields:
from : float3 - The world-space start position (projected onto the navmesh)
to : float3 - The world-space target position
ext : float3 = float3(0f,0f,0f) - Half-extents of the projection box, resolved per axis: a zero component takes the profile-derived default (so float3(0) is fully automatic, float3(0, 5, 0) widens only Y)
- NavPointQuery¶
Represents a request to project a position onto the navmesh.
- Fields:
pos : float3 - The world-space position to project
ext : float3 = float3(0f,0f,0f) - Half-extents of the projection box, resolved per axis: a zero component takes the profile-derived default (so float3(0) is fully automatic, float3(0, 5, 0) widens only Y)
- NavWallQuery¶
Represents a distance-to-wall request.
- Fields:
pos : float3 - The world-space position (projected onto the navmesh)
maxRadius : float = 5f - The search radius
ext : float3 = float3(0f,0f,0f) - Half-extents of the projection box, resolved per axis: a zero component takes the profile-derived default (so float3(0) is fully automatic, float3(0, 5, 0) widens only Y)
- NavCircleQuery¶
Represents a random-walkable-points request around a center position.
- Fields:
center : float3 - The world-space center of the search circle (projected onto the navmesh)
radius : float = 5f - The search radius (limits the visited polygons, so points are not exactly distance-constrained)
count : int = 1 - How many points to generate
seed : int = 0 - Random seed; 0 is non-deterministic (each call differs), any nonzero seed reproduces the same points
ext : float3 = float3(0f,0f,0f) - Half-extents of the projection box, resolved per axis: a zero component takes the profile-derived default (so float3(0) is fully automatic, float3(0, 5, 0) widens only Y)
- NavTraceHit¶
The wall hit reported by a navmesh walkability raycast when the ray is blocked.
- Fields:
position : float3 - The wall hit point lifted to the navmesh surface
normal : float3 - The wall normal in the XZ plane (y = 0)
- NavWallHit¶
The nearest wall reported by a distance-to-wall query.
- Fields:
position : float3 - The nearest point on the wall
normal : float3 - The normalized direction from the wall point back to the query position
distance : float - The distance from the (projected) query position to the wall