A* Pathfinding Project  4.3.2
The A* Pathfinding Project for Unity 3D
RVOObstacle Class Referenceabstract

Base class for simple RVO colliders. More...

Detailed Description

Base class for simple RVO colliders.

This is a helper base class for RVO colliders. It provides automatic gizmos and helps with the winding order of the vertices as well as automatically updating the obstacle when moved.

Extend this class to create custom RVO obstacles.

See also
Writing RVO Colliders

A* Pro Feature:
This is an A* Pathfinding Project Pro feature only. This function/class/variable might not exist in the Free version of the A* Pathfinding Project or the functionality might be limited
The Pro version can be bought here

Public Types

enum  ObstacleVertexWinding { KeepOut, KeepIn }
 RVO Obstacle Modes. More...

Public Member Functions

void OnDisable ()
 Disables the obstacle. More...
void OnDrawGizmos ()
 Draws Gizmos. More...
void OnDrawGizmos (bool selected)
 Draws Gizmos. More...
void OnDrawGizmosSelected ()
 Draws Gizmos. More...
void OnEnable ()
 Enabled the obstacle. More...
void Start ()
 Creates obstacles. More...
void Update ()
 Updates obstacle if required. More...

Public Attributes

RVOLayer layer = RVOLayer.DefaultObstacle
ObstacleVertexWinding obstacleMode
 Mode of the obstacle. More...

Protected Member Functions

void AddObstacle (Vector3[] vertices, float height)
 Adds an obstacle with the specified vertices. More...
abstract bool AreGizmosDirty ()
 Called in the editor. More...
abstract void CreateObstacles ()
 Create Obstacles. More...
void FindSimulator ()
 Finds a simulator in the scene. More...
virtual Matrix4x4 GetMatrix ()
 Get's the matrix to use for vertices. More...
- Protected Member Functions inherited from VersionedMonoBehaviour
virtual void Awake ()
virtual int OnUpgradeSerializedData (int version, bool unityThread)
 Handle serialization backwards compatibility. More...
virtual void Reset ()
 Handle serialization backwards compatibility. More...

Protected Attributes

Pathfinding.RVO.ISimulator sim
 Reference to simulator. More...


abstract bool ExecuteInEditor [get]
 Enable executing in editor to draw gizmos. More...
abstract float Height [get]
abstract bool LocalCoordinates [get]
 If enabled, all coordinates are handled as local. More...
abstract bool StaticObstacle [get]
 Static or dynamic. More...
- Properties inherited from VersionedMonoBehaviour
int Util.IEntityIndex. EntityIndex [get, set]
 Internal entity index used by #BurstBatchHelper. More...
- Properties inherited from IEntityIndex
int EntityIndex [get, set]

Private Member Functions

void AddObstacleInternal (Vector3[] vertices, float height)
 Adds an obstacle. More...
void WindCorrectly (Vector3[] vertices)
 Winds the vertices correctly. More...

Private Attributes

ObstacleVertexWinding _obstacleMode
 Last obstacle mode. More...
List< ObstacleVertexaddedObstacles
 All obstacles added. More...
bool gizmoDrawing = false
 Enabled if currently in OnDrawGizmos. More...
List< Vector3[]> gizmoVerts
 Vertices for gizmos. More...
Matrix4x4 prevUpdateMatrix
 Last matrix the obstacle was updated with. More...
List< Vector3[]> sourceObstacles
 Original vertices for the obstacles. More...

Member Enumeration Documentation

◆ ObstacleVertexWinding

enum ObstacleVertexWinding

RVO Obstacle Modes.

Determines winding order of obstacle vertices


Keeps agents from entering the obstacle.


Keeps agents inside the obstacle.

Member Function Documentation

◆ AddObstacle()

void AddObstacle ( Vector3 []  vertices,
float  height 

Adds an obstacle with the specified vertices.

The vertices array might be changed by this function.

◆ AddObstacleInternal()

void AddObstacleInternal ( Vector3 []  vertices,
float  height 

Adds an obstacle.

Winding is assumed to be correct and very little error checking is done.

◆ AreGizmosDirty()

abstract bool AreGizmosDirty ( )
protectedpure virtual

Called in the editor.

This function should return true if any variables which can change the shape or position of the obstacle has changed since the last call to this function. Take a look at the RVOSquareObstacle for an example.

Implemented in RVOSquareObstacle.

◆ CreateObstacles()

abstract void CreateObstacles ( )
protectedpure virtual

Create Obstacles.

Override this and add logic for creating obstacles. You should not use the simulator's function calls directly.

See also

Implemented in RVOSquareObstacle.

◆ FindSimulator()

void FindSimulator ( )

Finds a simulator in the scene.

Saves found simulator in sim.

System.InvalidOperationExceptionWhen no RVOSimulator could be found.

◆ GetMatrix()

virtual Matrix4x4 GetMatrix ( )

Get's the matrix to use for vertices.

Can be overriden for custom matrices.

transform.localToWorldMatrix if LocalCoordinates is true, otherwise Matrix4x4.identity

◆ OnDisable()

void OnDisable ( )

Disables the obstacle.

Do not override this function

◆ OnDrawGizmos() [1/2]

void OnDrawGizmos ( )

Draws Gizmos.

◆ OnDrawGizmos() [2/2]

void OnDrawGizmos ( bool  selected)

Draws Gizmos.

◆ OnDrawGizmosSelected()

void OnDrawGizmosSelected ( )

Draws Gizmos.

◆ OnEnable()

void OnEnable ( )

Enabled the obstacle.

Do not override this function

◆ Start()

void Start ( )

Creates obstacles.

◆ Update()

void Update ( )

Updates obstacle if required.

Checks for if the obstacle should be updated (e.g if it has moved)

◆ WindCorrectly()

void WindCorrectly ( Vector3 []  vertices)

Winds the vertices correctly.

Winding order is determined from obstacleMode.

Member Data Documentation

◆ _obstacleMode

ObstacleVertexWinding _obstacleMode

Last obstacle mode.

Used to check if the gizmos should be updated

◆ addedObstacles

List<ObstacleVertex> addedObstacles

All obstacles added.

◆ gizmoDrawing

bool gizmoDrawing = false

Enabled if currently in OnDrawGizmos.

◆ gizmoVerts

List<Vector3[]> gizmoVerts

Vertices for gizmos.

◆ layer

◆ obstacleMode

ObstacleVertexWinding obstacleMode

Mode of the obstacle.

Determines winding order of the vertices

◆ prevUpdateMatrix

Matrix4x4 prevUpdateMatrix

Last matrix the obstacle was updated with.

Used to check if the obstacle should be updated

◆ sim

Reference to simulator.

◆ sourceObstacles

List<Vector3[]> sourceObstacles

Original vertices for the obstacles.

Property Documentation

◆ ExecuteInEditor

abstract bool ExecuteInEditor

Enable executing in editor to draw gizmos.

If enabled, the CreateObstacles function will be executed in the editor as well in order to draw gizmos.

◆ Height

abstract float Height

◆ LocalCoordinates

abstract bool LocalCoordinates

If enabled, all coordinates are handled as local.

◆ StaticObstacle

abstract bool StaticObstacle

Static or dynamic.

This determines if the obstacle can be updated by e.g moving the transform around in the scene.

The documentation for this class was generated from the following file: