|
NavAI Documentation
|
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, Vector2[] vertices, 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[] poly) |
| override void | GetZonePolygon (IList< Vector2 > polygon) |
| abstract void | GetZonePolygon (System.Collections.Generic.IList< Vector2 > polygon) |
| Vector2 | GetZoneVertex (int i) |
| virtual 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] |
A PolygonObstacle is a MonoBehaviour that can be attached to objets to assign objects as navigation obstacles. The PolygonObstacle, in particular, is an obstacle whose collider is a generic simple polygon.
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.
|
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. |
|
stronginherited |
|
virtual |
| void NavAI.PolygonObstacle.EditorSetup | ( | Vector2 | localPosition, |
| float | localAngle, | ||
| Vector2 | localScale, | ||
| Vector2 [] | vertices, | ||
| ObstacleType | type, | ||
| CarveType | carve, | ||
| float | moveThreshold, | ||
| float | timeToStationary, | ||
| bool | carveOnlyStationary | ||
| ) |
Method used to setup the obstacle's variables.
| localPosition | Local position of the obstacle relative to it's transform position. |
| localAngle | Local Y axis angle of the obstacle in degrees relative to it's transform Y axis angle. |
| localScale | Local scale of the obstacle relative to it's transform lossy scale. |
| vertices | Vertices of the polygon in the obstacle's local space. |
| type | Obstacle type. |
| carve | Obstacle carve type. |
| moveThreshold | Obstacle movement threshold. |
| timeToStationary | Obstacle time to stationary. |
| carveOnlyStationary | Obstacle 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.
| Vector2 NavAI.PolygonObstacle.GetLocalVertex | ( | int | i | ) |
Gets the vertex i in the obstacle's local space.
| i | Index of the vertex. |
|
virtual |
Gets the obstacle collider polygon in the world space.
Implements NavAI.Obstacle.
|
virtual |
Gets the obstacle colider polygon in the world space.
| polygon | An array to be filled with the collider vertices. Array length must match the number of vertices of the obstacle. |
Implements NavAI.Obstacle.
| override void NavAI.PolygonObstacle.GetWorldPolygon | ( | IList< Vector3 > | polygon | ) |
|
pure virtualinherited |
Gets the obstacle collider polygon in the world space.
| polygon | A list to be filled with the collider vertices. The list must have write permission. |
| Vector3 NavAI.PolygonObstacle.GetWorldVertex | ( | int | i | ) |
Gets the vertex i in the world space.
| i | Index of the vertex. |
|
virtual |
Gets the obstacle collider polygon in it's zone local space.
Implements NavAI.Obstacle.
|
virtual |
Gets the obstacle colider polygon in it's zone local space.
| polygon | An array to be filled with the collider vertices. Array length must match the number of vertices of the obstacle. |
Implements NavAI.Obstacle.
| override void NavAI.PolygonObstacle.GetZonePolygon | ( | IList< Vector2 > | polygon | ) |
|
pure virtualinherited |
Gets the obstacle collider polygon in it's zone local space.
| polygon | A list to be filled with the collider vertices. The list must have write permission. |
| Vector2 NavAI.PolygonObstacle.GetZoneVertex | ( | int | i | ) |
Gets the vertex i in the obstacle's zone space.
| i | Index of the vertex. |
|
virtualinherited |
Loads the obstacle runtime variables.
| zone | Zone 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 in NavAI.CircleObstacle.
|
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.
|
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.
|
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.
|
protectedinherited |
Cossin of the localAngle.
|
protectedinherited |
Position of the obstacle in the obstacle local space (x, z).
This is the equivalent of an offset for the obstacle collider position.
|
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.
|
protectedinherited |
Scale of the obstacle in it's local space (x, z)
This is the equivalent of the obstacle collider size.
|
protectedinherited |
Sin of the localAngle.
|
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.
|
protectedinherited |
Number of vertices of the obstacle collider.
This is unused by obstacles that carve heightmap.
|
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.
|
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.
|
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.
|
protectedinherited |
Cossin of the zoneAngle.
This variable is stored to prevent recalculating the cossin when there are no changes to the angle.
|
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.
|
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.
|
protectedinherited |
Sin of the zoneAngle.
This variable is stored to prevent recalculating the cossin when there are no changes to the angle.
|
getinherited |
Gets true if the obstacle carve type is CarveHeightmap.
|
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.
|
getinherited |
Gets true if the obstacle carve type is CarveTriangulation.
|
getsetinherited |
Gets or sets if the obstacle is dirty.
|
getinherited |
Gets true if the obstacle carve type is DontCarve.
|
getinherited |
Gets true if the obstacle carve type is IgnoreObstacle.
|
getinherited |
Gets trye if the obstacle is active.
|
getinherited |
Gets true if the obstacle is carved on the triangulation.
|
getinherited |
Gets true if the obstacle type is dynamic.
|
getinherited |
Gets true if the obstacle type is static.
|
getinherited |
Gets true if the obstacle is currently stationary.
|
getinherited |
Gets the Y angle of the obstacle in it's local space.
This is the equivalent of the obstacle collider angle offset.
|
getinherited |
Gets the position of the obstacle in it's local space (X, Z).
This is the equivalent of the obstacle collider position offset.
|
getinherited |
Gets the scale of the obstacle in it's local space (X, Z).
This is the equivalent of the obstacle collider size.
|
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.
|
getprotected setinherited |
Gets the number of vertices of the obstacle.
This propriety is not used by obstacles that carve the heightmap.
|
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.
|
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.
|
getprotectedinherited |
Gets the movement threshold squared.
|
get |
|
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.
|
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.
|
getinherited |
Gets the world position of the obstacle.
This will be different from transform.position if the obstacle has a localPosition other than zero.
|
getinherited |
Gets the world radius in meters of the obstacle.
|
getinherited |
Gets the world scale of the obstacle.
This is the transform.lossyScale multiplied by the obstacle's localScale.
|
getsetinherited |
Gets the zone of the obstacle.
|
getinherited |
Gets the degrees Y angle of the obstacle in it's zone local space.
|
getinherited |
Gets the position of the obstacle in it's zone local space (X, Z).
This is the equivalent of Zone.WorldToLocalPoint(transform.position).
|
getinherited |
Gets the radius of the obstacle in it's zone local space.
|
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.