A* Pathfinding Project  4.3.5
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.

Classes

struct  JobGenerateMesh
 
struct  JobMoveAgents
 
struct  JobSetAgentSettings
 

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 OnDestroy ()
 
float uniformDistance (float radius)
 

Private Attributes

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

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.

◆ OnDestroy()

void OnDestroy ( )
private

◆ OnGUI()

void OnGUI ( )

◆ Start()

void Start ( )

◆ uniformDistance()

float uniformDistance ( float  radius)
private

◆ Update()

void Update ( )

Member Data Documentation

◆ agentColors

NativeArray<Color> agentColors
private

Color for each agent.

◆ 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.

◆ 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

NativeArray<float2> goals
private

Goals for each agent.

◆ interpolatedRotations

NativeArray<float2> interpolatedRotations
private

◆ interpolatedVelocities

NativeArray<float2> 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 = new Color[0]
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 = new int[0]
private

◆ type

◆ uv

Vector2 [] uv = new Vector2[0]
private

◆ verts

Vector3 [] verts = new Vector3[0]
private

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