A* Pathfinding Project  4.1.19
The A* Pathfinding Project for Unity 3D
LightweightRVO Class Reference

Lightweight RVO Circle Example. More...

Detailed Description

Lightweight RVO Circle Example.

Lightweight script for simulating agents in a circle trying to reach their antipodal positions. This script, compared to using lots of RVOAgents shows the real power of the RVO simulator when little other overhead (e.g GameObjects) is present.

For example with this script, I can simulate 5000 agents at around 50 fps on my laptop (with desired simulation fps = 10 and interpolation, 2 threads) however when using prefabs, only instantiating the 5000 agents takes 10 seconds and it runs at around 5 fps.

This script will render the agents by generating a square for each agent combined into a single mesh with appropriate UV.

A few GUI buttons will be drawn by this script with which the user can change the number of agents.

Public Types

enum  RVOExampleType {
  Circle, Line, Point, RandomStreams,
  Crossing
}
 

Public Member Functions

void CreateAgents (int num)
 Create a number of agents in circle and restart simulation. More...
 
void OnGUI ()
 
void Start ()
 
void Update ()
 

Public Attributes

int agentCount = 100
 Number of agents created at start. More...
 
float agentTimeHorizon = 10
 How far in the future too look for agents. More...
 
bool debug = false
 Enable the debug flag for all agents. More...
 
float exampleScale = 100
 How large is the area where agents are placed. More...
 
int maxNeighbours = 10
 Max number of neighbour agents to take into account. More...
 
float maxSpeed = 2
 Max speed for an agent. More...
 
float obstacleTimeHorizon = 10
 How far in the future too look for obstacles. More...
 
float radius = 3
 Agent radius. More...
 
Vector3 renderingOffset = Vector3.up*0.1f
 Offset from the agent position the actual drawn postition. More...
 
RVOExampleType type = RVOExampleType.Circle
 

Private Member Functions

void SetAgentSettings ()
 
float uniformDistance (float radius)
 

Private Attributes

List< IAgentagents
 All agents handled by this script. More...
 
List< Color > colors
 Color for each agent. More...
 
List< Vector3 > goals
 Goals for each agent. More...
 
Vector2 [] interpolatedRotations
 
Vector2 [] interpolatedVelocities
 
Mesh mesh
 Mesh for rendering. More...
 
Color [] meshColors
 
Pathfinding.RVO.Simulator sim
 Reference to the simulator in the scene. More...
 
int [] tris
 
Vector2 [] uv
 
Vector3 [] verts
 

Member Enumeration Documentation

◆ RVOExampleType

enum RVOExampleType
strong
Enumerator
Circle 
Line 
Point 
RandomStreams 
Crossing 

Member Function Documentation

◆ CreateAgents()

void CreateAgents ( int  num)

Create a number of agents in circle and restart simulation.

◆ OnGUI()

void OnGUI ( )

◆ SetAgentSettings()

void SetAgentSettings ( )
private

◆ Start()

void Start ( )

◆ uniformDistance()

float uniformDistance ( float  radius)
private

◆ Update()

void Update ( )

Member Data Documentation

◆ agentCount

int agentCount = 100

Number of agents created at start.

◆ agents

List<IAgent> agents
private

All agents handled by this script.

◆ agentTimeHorizon

float agentTimeHorizon = 10

How far in the future too look for agents.

◆ colors

List<Color> colors
private

Color for each agent.

◆ debug

bool debug = false

Enable the debug flag for all agents.

◆ exampleScale

float exampleScale = 100

How large is the area where agents are placed.

For e.g the circle example, it corresponds

◆ goals

List<Vector3> goals
private

Goals for each agent.

◆ interpolatedRotations

Vector2 [] interpolatedRotations
private

◆ interpolatedVelocities

Vector2 [] interpolatedVelocities
private

◆ maxNeighbours

int maxNeighbours = 10

Max number of neighbour agents to take into account.

◆ maxSpeed

float maxSpeed = 2

Max speed for an agent.

◆ mesh

Mesh mesh
private

Mesh for rendering.

◆ meshColors

Color [] meshColors
private

◆ obstacleTimeHorizon

float obstacleTimeHorizon = 10

How far in the future too look for obstacles.

◆ radius

float radius = 3

Agent radius.

◆ renderingOffset

Vector3 renderingOffset = Vector3.up*0.1f

Offset from the agent position the actual drawn postition.

Used to get rid of z-buffer issues

◆ sim

Reference to the simulator in the scene.

◆ tris

int [] tris
private

◆ type

◆ uv

Vector2 [] uv
private

◆ verts

Vector3 [] verts
private

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