Class Simulator

Public

Local Avoidance Simulator.

This class handles local avoidance simulation for a number of agents using Reciprocal Velocity Obstacles (RVO) and Optimal Reciprocal Collision Avoidance (ORCA).

This class will handle calculation of velocities from desired velocities supplied by a script. It is, however, not responsible for moving any objects in a Unity Scene. For that there are other scripts (see below).

Obstacles can be added and removed from the simulation, agents can also be added and removed at any time.

The implementation uses a sampling based algorithm with gradient descent to find the avoidance velocities.

You will most likely mostly use the wrapper class RVOSimulator.

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

Inner Types

Worker thread for RVO simulation.

Public Methods

AddAgent (agent)

Add a previously removed agent to the simulation.

Public
AddAgent (position, elevationCoordinate)

Add an agent at the specified position.

Public
AddObstacle (v)

Adds a previously removed obstacle.

Public
AddObstacle (vertices, height, cycle=true)

Adds an obstacle described by the vertices.

Public
AddObstacle (vertices, height, matrix, layer=…, cycle=true)

Adds an obstacle described by the vertices.

Public
AddObstacle (a, b, height)

Adds a line obstacle with a specified height.

Public
ClearAgents ()

Removes all agents from the simulation.

Public
GetAgents ()

Get a list of all agents.

Public
GetObstacles ()

Get a list of all obstacles.

Public
OnDestroy ()

Terminates all worker threads.

Public
RemoveAgent (agent)

Removes a specified agent from this simulation.

Public
RemoveObstacle (v)

Removes the obstacle identified by the vertex.

Public
Simulator (workers, doubleBuffering, movementPlane)

Create a new simulator.

Public
Update ()

Should be called once per frame.

Public
UpdateObstacle (obstacle, vertices, matrix)

Updates the vertices of an obstacle.

Public
UpdateObstacles ()

Rebuilds the obstacle tree at next simulation frame.

Public

Public Variables

DeltaTime
Public
DesiredDeltaTime

Time in seconds between each simulation step.

Public
Multithreading

Is using multithreading.

Public
Quadtree

Quadtree for this simulation.

Public
movementPlane

Determines if the XY (2D) or XZ (3D) plane is used for movement.

Public Readonly
obstacles

Obstacles in this simulation.

Public
symmetryBreakingBias

Bias agents to pass each other on the right side.

Public

Private/Protected Members

BlockUntilSimulationStepIsDone ()

Blocks until separate threads have finished with the current simulation step.

Private
BuildQuadtree ()
Private
CleanAndUpdateObstaclesIfNecessary ()
Private
CleanObstacles ()
Private
PreCalculation ()
Private
ScheduleCleanObstacles ()
Private
agents

Agents in this simulation.

Private
coroutineWorkerContext
Private
deltaTime
Private
desiredDeltaTime

Inverse desired simulation fps.

Private
doCleanObstacles
Private
doUpdateObstacles
Private
doubleBuffering

Use Double Buffering.

Private Readonly
lastStep
Private
workers

Worker threads.

Private Readonly

Deprecated Members

AddAgent (position)

Add an agent at the specified position.

Public