NavAI Documentation
NavAI.CircleObstacleabstract

Inherits NavAI.Obstacle.

Public Types

enum  CarveType { CarveType.CarveHeightmap, CarveType.CarveTriangulation, CarveType.DontCarve, CarveType.IgnoreObstacle }
 
enum  ObstacleType { ObstacleType.Static, ObstacleType.Dynamic }
 

Public Member Functions

override void Draw (Color color)
 
void EditorSetup (Vector2 localPosition, float localAngle, Vector2 localScale, int noVertices, ObstacleType type, CarveType carve, float moveThreshold, float timeToStationary, bool carveOnlyStationary)
 
Vector2 GetLocalVertex (int i)
 
override Vector3 [] GetWorldPolygon ()
 
override void GetWorldPolygon (Vector3[] polygon)
 
override void GetWorldPolygon (IList< Vector3 > polygon)
 
abstract void GetWorldPolygon (System.Collections.Generic.IList< Vector3 > polygon)
 
Vector3 GetWorldVertex (int i)
 
override Vector2 [] GetZonePolygon ()
 
override void GetZonePolygon (Vector2[] polygon)
 
override void GetZonePolygon (IList< Vector2 > polygon)
 
abstract void GetZonePolygon (System.Collections.Generic.IList< Vector2 > polygon)
 
Vector2 GetZoneVertex (int i)
 
override void Load (NavigationZone zone=null)
 

Protected Attributes

bool carveOnlyStationary
 
CarveType carveType
 
float localAngle
 
float localCos
 
Vector2 localPosition
 
float localRadius
 
Vector2 localScale
 
float localSin
 
float moveThreshold
 
int noVertices
 
float timeToStationary
 
ObstacleType type
 
float zoneAngle
 
float zoneCos
 
Vector2 zonePosition
 
Vector2 zoneScale
 
float zoneSin
 

Properties

bool CarveHeightMap [get]
 
bool CarveOnlyStationary [get, protected set]
 
bool CarveTriangulation [get]
 
bool Dirty [get, set]
 
bool DontCarve [get]
 
bool IgnoreObstacle [get]
 
bool IsActive [get]
 
bool IsCarved [get]
 
bool IsDynamic [get]
 
bool IsStatic [get]
 
bool IsStationary [get]
 
float LocalAngle [get]
 
Vector2 LocalPosition [get]
 
Vector2 LocalScale [get]
 
float MoveThreshold [get, protected set]
 
int NoVertices [get, protected set]
 
CarveType ObstCarveType [get, protected set]
 
ObstacleType ObstType [get, protected set]
 
float SqrMoveThreshold [get]
 
override Vector2 this[int i] [get]
 
float TimeToStationary [get, protected set]
 
float WorldAngle [get]
 
Vector3 WorldPosition [get]
 
float WorldRadius [get]
 
Vector3 WorldScale [get]
 
NavigationZone Zone [get, set]
 
float ZoneAngle [get]
 
Vector2 ZonePosition [get]
 
float ZoneRadius [get]
 
Vector2 ZoneScale [get]
 

Detailed Description

A CircleObstacle is a MonoBehaviour that can be attached to objets to assign objects as navigation obstacles. The CircleObstacle, in particular, is an obstacle whose collider is a circle.

Navigation obstacles colliders are 2D polygons that are not affected by the the object's Y coordinate or X and Z rotation axis, unless thei are flagged to carve the heightmap.

Member Enumeration Documentation

◆ CarveType

enum NavAI.Obstacle.CarveType
stronginherited

Carve type of the obstacle.

Enumerator
CarveHeightmap 

Obstacle is carved on the heightmap. This option will create a navmesh surface over the obstacle. Dynamic obstacles cannot carve the heightmap.

CarveTriangulation 

Obstacle is carved on the triangulation. The triangulation is used for pathfinding and other systems.

DontCarve 

Obstacle is not carved on the triangulation. Agents will avoid the obstacle using local collision avoidance only.

IgnoreObstacle 

Obstacle will be completely ignored by the navigation algorithms.

◆ ObstacleType

enum NavAI.Obstacle.ObstacleType
stronginherited

Type of obstacle according to how it is treated by the mesh.

Enumerator
Static 

Obstacle transform and properties cannot be changed at runtime.

Dynamic 

Obstacle transform and properties can be changed at runtime.

Member Function Documentation

◆ Draw()

override void NavAI.CircleObstacle.Draw ( Color  color)
virtual

Draws the obstacle collider.

Parameters
colorMaterial color.

Implements NavAI.Obstacle.

◆ EditorSetup()

void NavAI.CircleObstacle.EditorSetup ( Vector2  localPosition,
float  localAngle,
Vector2  localScale,
int  noVertices,
ObstacleType  type,
CarveType  carve,
float  moveThreshold,
float  timeToStationary,
bool  carveOnlyStationary 
)

Method used to setup the obstacle's variables.

Parameters
localPositionLocal position of the obstacle relative to it's transform position.
localAngleLocal Y axis angle of the obstacle in degrees relative to it's transform Y axis angle.
localScaleLocal scale of the obstacle relative to it's transform lossy scale.
noVerticesNumber of vertices of the obstacle's polygon.
typeObstacle type.
carveObstacle carve type.
moveThresholdObstacle movement threshold.
timeToStationaryObstacle time to stationary.
carveOnlyStationaryObstacle carve only stationary.

This method is used internally by the editor inspector to set up navigation obstacles. Even though it is possible to set up obstacles at runtime using this method, changing some obstacles variables may require baking the navmesh to take effect.

◆ GetLocalVertex()

Vector2 NavAI.CircleObstacle.GetLocalVertex ( int  i)

Gets the vertex i in the obstacle's local space.

Parameters
iThe vertex index.
Returns
The local vertex[i].

◆ GetWorldPolygon() [1/4]

override Vector3 [] NavAI.CircleObstacle.GetWorldPolygon ( )
virtual

Gets the obstacle collider polygon in the world space.

Returns
An array with the collider vertices.

Implements NavAI.Obstacle.

◆ GetWorldPolygon() [2/4]

override void NavAI.CircleObstacle.GetWorldPolygon ( Vector3 []  polygon)
virtual

Gets the obstacle colider polygon in the world space.

Parameters
polygonAn array to be filled with the collider vertices. Array length must match the number of vertices of the obstacle.

Implements NavAI.Obstacle.

◆ GetWorldPolygon() [3/4]

override void NavAI.CircleObstacle.GetWorldPolygon ( IList< Vector3 >  polygon)

◆ GetWorldPolygon() [4/4]

abstract void NavAI.Obstacle.GetWorldPolygon ( System.Collections.Generic.IList< Vector3 >  polygon)
pure virtualinherited

Gets the obstacle collider polygon in the world space.

Parameters
polygonA list to be filled with the collider vertices. The list must have write permission.

◆ GetWorldVertex()

Vector3 NavAI.CircleObstacle.GetWorldVertex ( int  i)

Gets the vertex i in the world space.

Parameters
iThe index of the vertex.
Returns
The vertex[i].

◆ GetZonePolygon() [1/4]

override Vector2 [] NavAI.CircleObstacle.GetZonePolygon ( )
virtual

Gets the obstacle collider polygon in it's zone local space.

Returns
An array containg the collider vertices.

Implements NavAI.Obstacle.

◆ GetZonePolygon() [2/4]

override void NavAI.CircleObstacle.GetZonePolygon ( Vector2 []  polygon)
virtual

Gets the obstacle colider polygon in it's zone local space.

Parameters
polygonAn array to be filled with the collider vertices. Array length must match the number of vertices of the obstacle.

Implements NavAI.Obstacle.

◆ GetZonePolygon() [3/4]

override void NavAI.CircleObstacle.GetZonePolygon ( IList< Vector2 >  polygon)

◆ GetZonePolygon() [4/4]

abstract void NavAI.Obstacle.GetZonePolygon ( System.Collections.Generic.IList< Vector2 >  polygon)
pure virtualinherited

Gets the obstacle collider polygon in it's zone local space.

Parameters
polygonA list to be filled with the collider vertices. The list must have write permission.

◆ GetZoneVertex()

Vector2 NavAI.CircleObstacle.GetZoneVertex ( int  i)

Gets the vertex i in the obstacle's zone space.

Parameters
iThe vertex index.
Returns
The zone vertex[i].

◆ Load()

override void NavAI.CircleObstacle.Load ( NavigationZone  zone = null)
virtual

Loads the obstacle runtime variables.

Parameters
zoneZone the obstacle is in.

This method is used internally to load the obstacle when it adquires a new zone, and also by the editor inspectors. There is no need for the user to use this function.

Reimplemented from NavAI.Obstacle.

Member Data Documentation

◆ carveOnlyStationary

bool NavAI.Obstacle.carveOnlyStationary
protectedinherited

Toggles carving the obstacle only when it is stationary.

If enabled, then the obstacle will be temporarely added to the obstacles KD-Tree while moving, and will be automatically remvoed from the tree and added to the navmesh triangulation when it becomes stationary.

◆ carveType

CarveType NavAI.Obstacle.carveType
protectedinherited

Obstacle carve type.

CarveHeightmap: The obstacle will be carved on the heightmap, generating a navmesh surface over it.

CarveTrianguylatiion: The obstacle will be carved on the triangulation, allowing the pathfinder and other systems to deal with this obstacle intelligently.

DontCarve: The obstacle will not be carved on the triangulation and will be kept on the obstacles KD-Tree. This means that agents will avoid this obstacle using local collision avoidance only, and the pathfinder will not be able to calcualte a path around this obstacle.

◆ localAngle

float NavAI.Obstacle.localAngle
protectedinherited

Degrees up axis (Y) angle of the obstacle in it's local space.

This is the equivalent of an offset for the obstacle collider Y angle.

◆ localCos

float NavAI.Obstacle.localCos
protectedinherited

Cossin of the localAngle.

◆ localPosition

Vector2 NavAI.Obstacle.localPosition
protectedinherited

Position of the obstacle in the obstacle local space (x, z).

This is the equivalent of an offset for the obstacle collider position.

◆ localRadius

float NavAI.Obstacle.localRadius
protectedinherited

Radius in meters of the bounding ball in the obstacle local space.

The bounding ball is a circle centered at the obstacle center that contains all obstacle collider points.

◆ localScale

Vector2 NavAI.Obstacle.localScale
protectedinherited

Scale of the obstacle in it's local space (x, z)

This is the equivalent of the obstacle collider size.

◆ localSin

float NavAI.Obstacle.localSin
protectedinherited

Sin of the localAngle.

◆ moveThreshold

float NavAI.Obstacle.moveThreshold
protectedinherited

Movement threshold in meters for the obstacle to be considered moving.

This is only used by dyanmic obstacles. Obstacles that have moved over the last frame will be flagged as dirty for the zone to update the triangulation or the obstacles KD-Tree.

Increasing this value can improve performance if there are too many dynamic obstacles in the scene.

◆ noVertices

int NavAI.Obstacle.noVertices
protectedinherited

Number of vertices of the obstacle collider.

This is unused by obstacles that carve heightmap.

◆ timeToStationary

float NavAI.Obstacle.timeToStationary
protectedinherited

Time not moving in seconds for the obstacle to be considered stationary.

This variable is used by dynamic obstacles flagged with carveOnlyStationary to determine when to carve the obstacle.

◆ type

ObstacleType NavAI.Obstacle.type
protectedinherited

Type of the obstacle as static or dynamic.

A static obstacle will be carved either on the heightmap or on the triangulation, and will not be able to change at runtime.

Dynamic obstacles cannot be carved on the heightmap, but can have their transform changed at runtime.

◆ zoneAngle

float NavAI.Obstacle.zoneAngle
protectedinherited

Up axis (Y) angle in degrees.

For performance and simplicty, we only keep track of the Y axis angle of obstacles. This means that rotating the obstacle using the X and Z axis will have no effect on the obstacle collider.

This field is only used by dynamic obstacles.

◆ zoneCos

float NavAI.Obstacle.zoneCos
protectedinherited

Cossin of the zoneAngle.

This variable is stored to prevent recalculating the cossin when there are no changes to the angle.

◆ zonePosition

Vector2 NavAI.Obstacle.zonePosition
protectedinherited

Position of the obstacle on the zone in the local zone coordinate system.

This is equivalent of Zone.WorldToLocalPoint(transform.position).

This field is only used by dynamic obstacles.

◆ zoneScale

Vector2 NavAI.Obstacle.zoneScale
protectedinherited

Scale of the obstacle on it's own local space (x, z).

Since the obstacle collider is roughly 2D, there is no need to keep track of the sacle on the Y axis.

It would be mathematically correct for this scale to affect the obstacle collider scaling on the zone coordinate system, but that would cause distortion of the obstacle collider, which is not the intention. Using this scale on the obstacle local space simply makes the collider larger, without distorting it.

This field is only used by dynamic obstacles.

◆ zoneSin

float NavAI.Obstacle.zoneSin
protectedinherited

Sin of the zoneAngle.

This variable is stored to prevent recalculating the cossin when there are no changes to the angle.

Property Documentation

◆ CarveHeightMap

bool NavAI.Obstacle.CarveHeightMap
getinherited

Gets true if the obstacle carve type is CarveHeightmap.

◆ CarveOnlyStationary

bool NavAI.Obstacle.CarveOnlyStationary
getprotected setinherited

Gets or sets carving the obstacle only when it is stationary.

If enabled, then the obstacle will be temporarely added to the obstacles KD-Tree while moving, and will be automatically remvoed from the tree and added to the navmesh triangulation when it becomes stationary.

◆ CarveTriangulation

bool NavAI.Obstacle.CarveTriangulation
getinherited

Gets true if the obstacle carve type is CarveTriangulation.

◆ Dirty

bool NavAI.Obstacle.Dirty
getsetinherited

Gets or sets if the obstacle is dirty.

◆ DontCarve

bool NavAI.Obstacle.DontCarve
getinherited

Gets true if the obstacle carve type is DontCarve.

◆ IgnoreObstacle

bool NavAI.Obstacle.IgnoreObstacle
getinherited

Gets true if the obstacle carve type is IgnoreObstacle.

◆ IsActive

bool NavAI.Obstacle.IsActive
getinherited

Gets trye if the obstacle is active.

◆ IsCarved

bool NavAI.Obstacle.IsCarved
getinherited

Gets true if the obstacle is carved on the triangulation.

◆ IsDynamic

bool NavAI.Obstacle.IsDynamic
getinherited

Gets true if the obstacle type is dynamic.

◆ IsStatic

bool NavAI.Obstacle.IsStatic
getinherited

Gets true if the obstacle type is static.

◆ IsStationary

bool NavAI.Obstacle.IsStationary
getinherited

Gets true if the obstacle is currently stationary.

◆ LocalAngle

float NavAI.Obstacle.LocalAngle
getinherited

Gets the Y angle of the obstacle in it's local space.

This is the equivalent of the obstacle collider angle offset.

◆ LocalPosition

Vector2 NavAI.Obstacle.LocalPosition
getinherited

Gets the position of the obstacle in it's local space (X, Z).

This is the equivalent of the obstacle collider position offset.

◆ LocalScale

Vector2 NavAI.Obstacle.LocalScale
getinherited

Gets the scale of the obstacle in it's local space (X, Z).

This is the equivalent of the obstacle collider size.

◆ MoveThreshold

float NavAI.Obstacle.MoveThreshold
getprotected setinherited

Gets or sets the movement threshold in meters for the obstacle to be considered moving.

This is only used by dyanmic obstacles. Obstacles that have moved over the last frame will be flagged as dirty for the zone to update the triangulation or the obstacles KD-Tree.

Increasing this value can improve performance if there are too many dynamic obstacles in the scene.

◆ NoVertices

int NavAI.Obstacle.NoVertices
getprotected setinherited

Gets the number of vertices of the obstacle.

This propriety is not used by obstacles that carve the heightmap.

◆ ObstCarveType

CarveType NavAI.Obstacle.ObstCarveType
getprotected setinherited

Gets or sets the obstacle carve type.

CarveHeightmap: The obstacle will be carved on the heightmap, generating a navmesh surface over it.

CarveTrianguylatiion: The obstacle will be carved on the triangulation, allowing the pathfinder and other systems to deal with this obstacle intelligently.

DontCarve: The obstacle will not be carved on the triangulation and will be kept on the obstacles KD-Tree. This means that agents will avoid this obstacle using local collision avoidance only, and the pathfinder will not be able to calcualte a path around this obstacle.

◆ ObstType

ObstacleType NavAI.Obstacle.ObstType
getprotected setinherited

Gets or sets the type of the obstacle.

A static obstacle will be carved either on the heightmap or on the triangulation, and will not be able to change at runtime.

Dynamic obstacles cannot be carved on the heightmap, but can have their transform changed at runtime.

◆ SqrMoveThreshold

float NavAI.Obstacle.SqrMoveThreshold
getprotectedinherited

Gets the movement threshold squared.

◆ this[int i]

override Vector2 NavAI.CircleObstacle.this[int i]
get

◆ TimeToStationary

float NavAI.Obstacle.TimeToStationary
getprotected setinherited

Gets or sets the time not moving in seconds for the obstacle to be considered stationary.

This variable is used by dynamic obstacles flagged with carveOnlyStationary to determine when to carve the obstacle.

◆ WorldAngle

float NavAI.Obstacle.WorldAngle
getinherited

Gets the world Y angle of the obstacle in degrees.

This will be different from transform.position if the obstacle has a localAngle other than zero.

◆ WorldPosition

Vector3 NavAI.Obstacle.WorldPosition
getinherited

Gets the world position of the obstacle.

This will be different from transform.position if the obstacle has a localPosition other than zero.

◆ WorldRadius

float NavAI.Obstacle.WorldRadius
getinherited

Gets the world radius in meters of the obstacle.

◆ WorldScale

Vector3 NavAI.Obstacle.WorldScale
getinherited

Gets the world scale of the obstacle.

This is the transform.lossyScale multiplied by the obstacle's localScale.

◆ Zone

NavigationZone NavAI.Obstacle.Zone
getsetinherited

Gets the zone of the obstacle.

◆ ZoneAngle

float NavAI.Obstacle.ZoneAngle
getinherited

Gets the degrees Y angle of the obstacle in it's zone local space.

◆ ZonePosition

Vector2 NavAI.Obstacle.ZonePosition
getinherited

Gets the position of the obstacle in it's zone local space (X, Z).

This is the equivalent of Zone.WorldToLocalPoint(transform.position).

◆ ZoneRadius

float NavAI.Obstacle.ZoneRadius
getinherited

Gets the radius of the obstacle in it's zone local space.

◆ ZoneScale

Vector2 NavAI.Obstacle.ZoneScale
getinherited

Gets the scale of the obstacle in it's zone local space.

Since the obstacle collider is roughly 2D, there is no need to keep track of the sacle on the Y axis.

It would be mathematically correct for this scale to affect the obstacle collider scaling on the zone coordinate system, but that would cause distortion of the obstacle collider, which is not the intention. Using this scale on the obstacle local space simply makes the collider larger, without distorting it.

This field is only used by dynamic obstacles.