NavAI Documentation
NavAI.NavigationWorld

Inherits MonoBehaviour.

Static Public Member Functions

static Path FindPathImmediate (Vector3 from, Vector3 to, float radius)
 
static void GetAllAgentsInRange (Vector3 point, float range, IList< Agent > agents)
 
static float GetHeight (Vector3 point)
 
static Vector3 GetMeshPoint (Vector3 point, float radius)
 
static Vector3 GetMeshPoint (Vector3 point, float radius, out NavigationZone zone)
 
static Agent GetNearestAgent (Vector3 point)
 
static Vector3 GetSurfacePoint (Vector3 point)
 
static NavigationZone GetZone (Agent agent)
 
static NavigationZone GetZone (Vector3 point)
 
static NavigationZone GetZone (int index)
 
static bool QueryCollision (Vector3 point, float radius)
 
static bool QueryMovement (Vector3 from, Vector3 to, float radius)
 
static bool QueryVisibility (Vector3 from, Vector3 to)
 

Properties

static NavigationWorld Instance [get]
 
static Thread MainThread [get, set]
 
static Settings WorldSettings [get]
 
static int ZoneCount [get]
 

Detailed Description

The NavigationWorld is a singleton MonoBehaviour that manages all the active NavigationZones on the scene. Use this class static methods when there are more than one active NavigationZone on the scene.

Member Function Documentation

◆ FindPathImmediate()

static Path NavAI.NavigationWorld.FindPathImmediate ( Vector3  from,
Vector3  to,
float  radius 
)
static

Finds the path from the start point to the goal point.

Parameters
fromInitial path world point.
toDestination path world point.
radiusPath radius in meters.
Returns
The path connecting the two points.

This process is not multi-threaded and may cause performance problems. Use of this meothd is not recommended.

The path will be available immediately after this method call. Be sure to check if the path found is not invalid.

◆ GetAllAgentsInRange()

static void NavAI.NavigationWorld.GetAllAgentsInRange ( Vector3  point,
float  range,
IList< Agent agents 
)
static

Fills the list with all agents in range of the point.

Parameters
pointPoint used for the query.
rangeQuery search range in meters.
agentsList to be filled with agents.

Agent distances to the point are compared using the distance between the point and the agent collision radius.This means that agent size can affect the result.

◆ GetHeight()

static float NavAI.NavigationWorld.GetHeight ( Vector3  point)
static

Gets the surface height of the world point.

Parameters
pointThe world point used for the query.
Returns
The height of the nearest surface point. NaN if there is no surface point above or below the input point.

◆ GetMeshPoint() [1/2]

static Vector3 NavAI.NavigationWorld.GetMeshPoint ( Vector3  point,
float  radius 
)
static

Gets the collision-free mesh point closest to the input point.

Parameters
pointThe world point used for the query.
radiusThe collision radius for the point in meters.
Returns
The world collision-free mesh point (x, height, z). Returns (NaN, NaN, NaN) if no valid collision-free mesh point was found.

This method will search all active zones and will return the mesh point nearest to the input world point with a minimum radius distance of an obstacle.

◆ GetMeshPoint() [2/2]

static Vector3 NavAI.NavigationWorld.GetMeshPoint ( Vector3  point,
float  radius,
out NavigationZone  zone 
)
static

Gets the collision-free mesh point closest to the input point.

Parameters
pointThe world point used for the query.
radiusThe collision radius for the point in meters.
zoneThe zone containing the world point.
Returns
The world collision-free mesh point (x, height, z). Returns (NaN, NaN, NaN) if no valid collision-free mesh point was found.

This method will search all active zones and will return the mesh point nearest to the input world point with a minimum radius distance of an obstacle.

◆ GetNearestAgent()

static Agent NavAI.NavigationWorld.GetNearestAgent ( Vector3  point)
static

Gets the nearest agent to the point.

Parameters
pointWorld point used for the query.
Returns
The nearest agent of the point.

Agent distances to the point are compared using the distance between the point and the agent collision radius.This means that agent size can affect the result.

◆ GetSurfacePoint()

static Vector3 NavAI.NavigationWorld.GetSurfacePoint ( Vector3  point)
static

Gets the world surface point with (x, height, z) coordinates.

Parameters
pointThe world point used for the query.
Returns
The world surface point (x, height, z). Returns (NaN, NaN, NaN) if no surface was found for the point.

This method will search all active zones and will return the surface point nearest to the input world point.

◆ GetZone() [1/3]

static NavigationZone NavAI.NavigationWorld.GetZone ( Agent  agent)
static

Gets the zone containing the agent.

Parameters
agentThe agent used for the query.
Returns
The zone containing the agent. Null if there is no zone containing the agent.

GetZone may return a different zone from Agent.Zone.

◆ GetZone() [2/3]

static NavigationZone NavAI.NavigationWorld.GetZone ( Vector3  point)
static

Gets the zone containing the world point.

Parameters
pointThe point used for the query.
Returns
The zone containg the point. Null if there is no zone containing the point.

◆ GetZone() [3/3]

static NavigationZone NavAI.NavigationWorld.GetZone ( int  index)
static

Gets the zone with the given index.

Parameters
indexThe index used for the query.
Returns
The zone with the given index.

This method gets the zone stored in the world zones list at the given index. Directly accessing the zone should only be done when there is only one active zone on the scene. In such case, use GetZone(0) to get the only active zone on the scene. If there are two or more active zones on the scene, this method is not recommended for use.

◆ QueryCollision()

static bool NavAI.NavigationWorld.QueryCollision ( Vector3  point,
float  radius 
)
static

Returns true if the point is colliding with an obstacle.

Parameters
pointThe point used for the query.
radiusThe collision radius used for the query in meters.
Returns
True if the point is within radius distance of an obstacle.

This method only considers collisions with obstacles that are carved on the mesh and does not consider collisions with agents.

◆ QueryMovement()

static bool NavAI.NavigationWorld.QueryMovement ( Vector3  from,
Vector3  to,
float  radius 
)
static

Returns true if the movement between the two points can be done with the given radius without colliding with any obstacles.

Parameters
fromInitial query world point.
toDestinatin query world point.
radiusCollision radius for the movement in meters.
Returns
True if the movement between the two points is possible for the given radius.

This method is equivalent to CapsuleCast, but it considers the navmesh triangles instead of object colliders. Only obstacles that are carved on the triangulation are considered for this query.

◆ QueryVisibility()

static bool NavAI.NavigationWorld.QueryVisibility ( Vector3  from,
Vector3  to 
)
static

Returns true if the points are visible to one another.

Parameters
fromInitial query world point.
toDestination query world point.
Returns
True if the points are visible to one another.

This method is equivalent to Unity's Physics.Raycast, but it considers the navmesh triangles instead of object colliders. Only obstacles that are carved on the triangulation are considered for this query.

Property Documentation

◆ Instance

NavigationWorld NavAI.NavigationWorld.Instance
staticget

Gets the active instance of the NavigationWorld.

If no instance is active, a new one will be created. When called from out-side the main thread, if there is no instance active, the return value will be null.

◆ MainThread

Thread NavAI.NavigationWorld.MainThread
staticgetset

Gets the main thread assigned to NavAI.

Since Unity Editor can use a different thread for the Editor, this propriety may be inaccurate when called from the editor.

◆ WorldSettings

Settings NavAI.NavigationWorld.WorldSettings
staticget

Gets the world settings file.

The world settings file is used for agents and obstacles that are not placed in a zone.

◆ ZoneCount

int NavAI.NavigationWorld.ZoneCount
staticget

Gets the number of active zones on the scene.