A* Pathfinding Project
3.8.12
The A* Pathfinding Project for Unity 3D
|
Lightweight RVO Circle Example. More...
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 } |
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 | neighbourDist = 15 |
Max distance for other agents to take them into account. | |
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 | |
float | uniformDistance (float radius) |
Static Private Member Functions | |
static Color | HSVToRGB (float h, float s, float v) |
Converts an HSV color to an RGB color, according to the algorithm described at http://en.wikipedia.org/wiki/HSL_and_HSV. | |
Private Attributes | |
List< IAgent > | agents |
All agents handled by this script. | |
List< Color > | colors |
Color for each agent. | |
List< Vector3 > | goals |
Goals for each agent. | |
Vector3[] | 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 |
enum RVOExampleType |
void CreateAgents | ( | int | num | ) |
Create a number of agents in circle and restart simulation.
|
staticprivate |
Converts an HSV color to an RGB color, according to the algorithm described at http://en.wikipedia.org/wiki/HSL_and_HSV.
h,s,v | the color to convert. |
void OnGUI | ( | ) |
void Start | ( | ) |
|
private |
void Update | ( | ) |
int agentCount = 100 |
Number of agents created at start.
|
private |
All agents handled by this script.
float agentTimeHorizon = 10 |
How far in the future too look for agents.
|
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
|
private |
Goals for each agent.
|
private |
int maxNeighbours = 10 |
Max number of neighbour agents to take into account.
float maxSpeed = 2 |
Max speed for an agent.
|
private |
Mesh for rendering.
|
private |
float neighbourDist = 15 |
Max distance for other agents to take them into account.
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
|
private |
Reference to the simulator in the scene.
|
private |
RVOExampleType type = RVOExampleType.Circle |
|
private |
|
private |