A* Pathfinding Project  3.8
The A* Pathfinding Project for Unity 3D
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Properties Events Macros Groups Pages
Agent Class Reference

Classes

struct  VO
 

Public Member Functions

 Agent (Vector3 pos)
 
void BufferSwitch ()
 
void CalculateNeighbours ()
 
float InsertAgentNeighbour (Agent agent, float rangeSq)
 
void InsertObstacleNeighbour (ObstacleVertex ob1, float rangeSq)
 
void Interpolate (float t)
 
void SetYPosition (float yCoordinate)
 
void Teleport (Vector3 pos)
 
void Update ()
 
- Public Member Functions inherited from IAgent
void SetYPosition (float yCoordinate)
 Sets the Y coordinate of the agent only.
 
void Teleport (Vector3 pos)
 Teleports the agent to a new position.
 

Static Public Member Functions

static bool IntersectionFactor (Vector2 start1, Vector2 dir1, Vector2 start2, Vector2 dir2, out float factor)
 Returns the intersection factors for line 1 and line 2.
 

Public Attributes

bool locked = false
 
int maxNeighbours
 
List< float > neighbourDists = new List<float>()
 
List< Agentneighbours = new List<Agent>()
 
Vector3 position
 
float radius
 
Simulator simulator
 Simulator which handles this agent.
 

Static Public Attributes

static float DesiredVelocityScale = 0.1f
 
static float DesiredVelocityWeight = 0.02f
 
static float GlobalIncompressibility = 30
 
static System.Diagnostics.Stopwatch watch1 = new System.Diagnostics.Stopwatch()
 
static System.Diagnostics.Stopwatch watch2 = new System.Diagnostics.Stopwatch()
 

Package Functions

void CalculateVelocity (Pathfinding.RVO.Simulator.WorkerContext context)
 

Package Attributes

Vector3 newVelocity
 
Agent next
 Used internally for a linked list.
 

Properties

float AgentTimeHorizon [get, set]
 
RVOLayer CollidesWith [get, set]
 
bool DebugDraw [get, set]
 
Vector3 DesiredVelocity [get, set]
 
float Height [get, set]
 
Vector3 InterpolatedPosition [get]
 
RVOLayer Layer [get, set]
 
bool Locked [get, set]
 
int MaxNeighbours [get, set]
 
float MaxSpeed [get, set]
 
float NeighbourDist [get, set]
 
List< ObstacleVertexNeighbourObstacles [get]
 
float ObstacleTimeHorizon [get, set]
 
Vector3 Position [get, set]
 
float Radius [get, set]
 
Vector3 Velocity [get, set]
 
- Properties inherited from IAgent
float AgentTimeHorizon [get, set]
 Max number of estimated seconds to look into the future for collisions with agents.
 
RVOLayer CollidesWith [get, set]
 Layer mask specifying which layers this agent will avoid.
 
bool DebugDraw [get, set]
 Debug drawing.
 
Vector3 DesiredVelocity [get, set]
 Desired velocity of the agent.
 
float Height [get, set]
 Height of the agent.
 
Vector3 InterpolatedPosition [get]
 Interpolated position of agent.
 
RVOLayer Layer [get, set]
 Specifies the avoidance layer for this agent.
 
bool Locked [get, set]
 Locked agents will not move.
 
int MaxNeighbours [get, set]
 Max number of agents to take into account.
 
float MaxSpeed [get, set]
 Max speed of the agent.
 
float NeighbourDist [get, set]
 Max distance to other agents to take them into account.
 
List< ObstacleVertexNeighbourObstacles [get]
 List of obstacle segments which were close to the agent during the last simulation step.
 
float ObstacleTimeHorizon [get, set]
 Max number of estimated seconds to look into the future for collisions with obstacles.
 
Vector3 Position [get]
 Position of the agent.
 
float Radius [get, set]
 Radius of the agent.
 
Vector3 Velocity [get, set]
 Velocity of the agent.
 

Private Member Functions

float Sqr (float x)
 
Vector2 Trace (VO[] vos, int voCount, Vector2 p, float cutoff, out float score)
 Traces the vector field constructed out of the velocity obstacles.
 

Static Private Member Functions

static void DrawCircle (Vector2 _p, float radius, Color col)
 
static void DrawCircle (Vector2 _p, float radius, float a0, float a1, Color col)
 
static void DrawCross (Vector2 p, float size=1)
 
static void DrawCross (Vector2 p, Color col, float size=1)
 
static void DrawVO (Vector2 circleCenter, float radius, Vector2 origin)
 
static Color Rainbow (float v)
 
static Vector3 To3D (Vector2 p)
 

Private Attributes

float agentTimeHorizon
 
RVOLayer collidesWith
 
Vector3 desiredVelocity
 
float height
 
RVOLayer layer
 
float maxSpeed
 
float neighbourDist
 
List< float > obstacleDists = new List<float>()
 
List< ObstacleVertexobstacles = new List<ObstacleVertex>()
 
List< ObstacleVertexobstaclesBuffered = new List<ObstacleVertex>()
 
float obstacleTimeHorizon
 
Vector3 prevSmoothPos
 
Vector3 smoothPos
 
Vector3 velocity
 
const float WallWeight = 5
 Extra weight that walls will have.
 
float weight
 

Constructor & Destructor Documentation

Agent ( Vector3  pos)

Member Function Documentation

void BufferSwitch ( )
void CalculateNeighbours ( )
void CalculateVelocity ( Pathfinding.RVO.Simulator.WorkerContext  context)
package
static void DrawCircle ( Vector2  _p,
float  radius,
Color  col 
)
staticprivate
static void DrawCircle ( Vector2  _p,
float  radius,
float  a0,
float  a1,
Color  col 
)
staticprivate
static void DrawCross ( Vector2  p,
float  size = 1 
)
staticprivate
static void DrawCross ( Vector2  p,
Color  col,
float  size = 1 
)
staticprivate
static void DrawVO ( Vector2  circleCenter,
float  radius,
Vector2  origin 
)
staticprivate
float InsertAgentNeighbour ( Agent  agent,
float  rangeSq 
)
void InsertObstacleNeighbour ( ObstacleVertex  ob1,
float  rangeSq 
)
void Interpolate ( float  t)
static bool IntersectionFactor ( Vector2  start1,
Vector2  dir1,
Vector2  start2,
Vector2  dir2,
out float  factor 
)
static

Returns the intersection factors for line 1 and line 2.

The intersection factors is a distance along the line start - end where the other line intersects it.

intersectionPoint = start1 + factor1 * (end1-start1)
intersectionPoint2 = start2 + factor2 * (end2-start2)

Lines are treated as infinite.
false is returned if the lines are parallel and true if they are not.

static Color Rainbow ( float  v)
staticprivate
void SetYPosition ( float  yCoordinate)
float Sqr ( float  x)
private
void Teleport ( Vector3  pos)
static Vector3 To3D ( Vector2  p)
staticprivate
Vector2 Trace ( VO[]  vos,
int  voCount,
Vector2  p,
float  cutoff,
out float  score 
)
private

Traces the vector field constructed out of the velocity obstacles.

Returns the position which gives the minimum score (approximately).

void Update ( )

Member Data Documentation

float agentTimeHorizon
private
RVOLayer collidesWith
private
Vector3 desiredVelocity
private
float DesiredVelocityScale = 0.1f
static
float DesiredVelocityWeight = 0.02f
static
float GlobalIncompressibility = 30
static
float height
private
RVOLayer layer
private
bool locked = false
int maxNeighbours
float maxSpeed
private
float neighbourDist
private
List<float> neighbourDists = new List<float>()
List<Agent> neighbours = new List<Agent>()
Vector3 newVelocity
package
Agent next
package

Used internally for a linked list.

List<float> obstacleDists = new List<float>()
private
List<ObstacleVertex> obstacles = new List<ObstacleVertex>()
private
List<ObstacleVertex> obstaclesBuffered = new List<ObstacleVertex>()
private
float obstacleTimeHorizon
private
Vector3 position
Vector3 prevSmoothPos
private
float radius
Simulator simulator

Simulator which handles this agent.

Used by this script as a reference and to prevent adding this agent to multiple simulations.

Vector3 smoothPos
private
Vector3 velocity
private
const float WallWeight = 5
private

Extra weight that walls will have.

System.Diagnostics.Stopwatch watch1 = new System.Diagnostics.Stopwatch()
static
System.Diagnostics.Stopwatch watch2 = new System.Diagnostics.Stopwatch()
static
float weight
private

Property Documentation

float AgentTimeHorizon
getset
RVOLayer CollidesWith
getset
bool DebugDraw
getset
Vector3 DesiredVelocity
getset
float Height
getset
Vector3 InterpolatedPosition
get
RVOLayer Layer
getset
bool Locked
getset
int MaxNeighbours
getset
float MaxSpeed
getset
float NeighbourDist
getset
List<ObstacleVertex> NeighbourObstacles
get
float ObstacleTimeHorizon
getset
Vector3 Position
getset
float Radius
getset
Vector3 Velocity
getset

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