A* Pathfinding Project  4.0.7
The A* Pathfinding Project for Unity 3D
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Properties Events Macros Groups Pages
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.
 
void OnGUI ()
 
void Start ()
 
void Update ()
 

Public Attributes

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

Private Member Functions

void SetAgentSettings ()
 
float uniformDistance (float radius)
 

Private Attributes

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

Member Enumeration Documentation

Enumerator:
Circle 
Line 
Point 
RandomStreams 
Crossing 

Member Function Documentation

void CreateAgents ( int  num)

Create a number of agents in circle and restart simulation.

void OnGUI ( )
void SetAgentSettings ( )
private
void Start ( )
float uniformDistance ( float  radius)
private
void Update ( )

Member Data Documentation

int agentCount = 100

Number of agents created at start.

List<IAgent> agents
private

All agents handled by this script.

float agentTimeHorizon = 10

How far in the future too look for agents.

List<Color> colors
private

Color for each agent.

bool debug = false

Enable the debug flag for all agents.

float exampleScale = 100

How large is the area where agents are placed.

For e.g the circle example, it corresponds

List<Vector3> goals
private

Goals for each agent.

Vector2 [] interpolatedRotations
private
Vector2 [] interpolatedVelocities
private
int maxNeighbours = 10

Max number of neighbour agents to take into account.

float maxSpeed = 2

Max speed for an agent.

Mesh mesh
private

Mesh for rendering.

Color [] meshColors
private
float obstacleTimeHorizon = 10

How far in the future too look for obstacles.

float radius = 3

Agent radius.

Vector3 renderingOffset = Vector3.up*0.1f

Offset from the agent position the actual drawn postition.

Used to get rid of z-buffer issues

Reference to the simulator in the scene.

int [] tris
private
RVOExampleType type = RVOExampleType.Circle
Vector2 [] uv
private
Vector3 [] verts
private

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