A* Pathfinding Project  3.8.5
The A* Pathfinding Project for Unity 3D
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Properties Events Macros Groups Pages
IAgent Interface Reference

Exposes properties of an Agent class. More...

Detailed Description

Exposes properties of an Agent class.

A* Pro Feature:
This is an A* Pathfinding Project Pro feature only. This function/class/variable might not exist in the Free version of the A* Pathfinding Project or the functionality might be limited
The Pro version can be bought here

Public Member Functions

void ForceSetVelocity (Vector2 velocity)
 Set the current velocity of the agent.
 
void SetCollisionNormal (Vector2 normal)
 Set the normal of a wall (or something else) the agent is currently colliding with.
 
void SetTarget (Vector2 targetPoint, float desiredSpeed, float maxSpeed)
 Desired velocity of the agent.
 

Properties

float AgentTimeHorizon [get, set]
 Max number of estimated seconds to look into the future for collisions with agents.
 
float CalculatedSpeed [get]
 Optimal speed of the agent to avoid collisions.
 
Vector2 CalculatedTargetPoint [get]
 Optimal point to move towards to avoid collisions.
 
RVOLayer CollidesWith [get, set]
 Layer mask specifying which layers this agent will avoid.
 
bool DebugDraw [get, set]
 Debug drawing.
 
float ElevationCoordinate [get, set]
 Coordinate which separates characters in the height direction.
 
float Height [get, set]
 Height of the agent in world units.
 
RVOLayer Layer [get, set]
 Specifies the avoidance layer for this agent.
 
bool Locked [get, set]
 Locked agents will be assumed not to move.
 
int MaxNeighbours [get, set]
 Max number of agents to take into account.
 
MovementMode MovementMode [get, set]
 Plane which movement is primarily happening in.
 
int NeighbourCount [get]
 Number of neighbours that the agent took into account during the last simulation step.
 
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.
 
Vector2 Position [get, set]
 Position of the agent.
 
System.Action PreCalculationCallback [set]
 Callback which will be called right before avoidance calculations are started.
 
float Priority [get, set]
 How strongly other agents will avoid this agent.
 
float Radius [get, set]
 Radius of the agent in world units.
 

Member Function Documentation

void ForceSetVelocity ( Vector2  velocity)

Set the current velocity of the agent.

This will override the local avoidance input completely. It is useful if you have a player controlled character and want other agents to avoid it.

Calling this method will mark the agent as being externally controlled for 1 simulation step. Local avoidance calculations will be skipped for the next simulation step but will be resumed after that unless this method is called again.

void SetCollisionNormal ( Vector2  normal)

Set the normal of a wall (or something else) the agent is currently colliding with.

This is used to make the RVO system aware of things like physics or an agent being clamped to the navmesh. The velocity of this agent that other agents observe will be modified so that there is no component into the wall. The agent will however not start to avoid the wall, for that you will need to add RVO obstacles.

This value will be cleared after the next simulation step, normally it should be set every frame when the collision is still happening.

void SetTarget ( Vector2  targetPoint,
float  desiredSpeed,
float  maxSpeed 
)

Desired velocity of the agent.

Usually you set this once per frame. The agent will try move as close to the desired velocity as possible. Will take effect at the next simulation step.Max speed of the agent. In units per second

Property Documentation

float AgentTimeHorizon
getset

Max number of estimated seconds to look into the future for collisions with agents.

As it turns out, this variable is also very good for controling agent avoidance priorities. Agents with lower values will avoid other agents less and thus you can make 'high priority agents' by giving them a lower value.

float CalculatedSpeed
get

Optimal speed of the agent to avoid collisions.

The movement script should move towards CalculatedTargetPoint with this speed.

Vector2 CalculatedTargetPoint
get

Optimal point to move towards to avoid collisions.

The movement script should move towards this point with a speed of CalculatedSpeed

RVOLayer CollidesWith
getset

Layer mask specifying which layers this agent will avoid.

You can set it as CollidesWith = RVOLayer.DefaultAgent | RVOLayer.Layer3 | RVOLayer.Layer6 ...

See Also
http://en.wikipedia.org/wiki/Mask_(computing)
bool DebugDraw
getset

Debug drawing.

Note
Assumes that the Position is in XZ space and the ElevationCoordinate is the Y coordinate.
Warning
This will only work if multithreading on the simulator component has been disabled since Unity's Debug API can only be called from the main thread.
float ElevationCoordinate
getset

Coordinate which separates characters in the height direction.

Since RVO can be used either in 2D or 3D, it is not as simple as just using the y coordinate of the 3D position. In 3D this will most likely be set to the y coordinate, but in 2D (top down) it should most likely be set to 0 since all characters are always in the same plane, however it may be set to some other value, for example if the game is 2D isometric.

float Height
getset

Height of the agent in world units.

Agents are modelled as circles/cylinders.

RVOLayer Layer
getset

Specifies the avoidance layer for this agent.

The CollidesWith mask on other agents will determine if they will avoid this agent.

bool Locked
getset

Locked agents will be assumed not to move.

int MaxNeighbours
getset

Max number of agents to take into account.

Decreasing this value can lead to better performance, increasing it can lead to better quality of the simulation.

Plane which movement is primarily happening in.

Note
All agents and obstacles need to have this value set to the same value
int NeighbourCount
get

Number of neighbours that the agent took into account during the last simulation step.

float NeighbourDist
getset

Max distance to other agents to take them into account.

Decreasing this value can lead to better performance, increasing it can lead to better quality of the simulation.

List<ObstacleVertex> NeighbourObstacles
get

List of obstacle segments which were close to the agent during the last simulation step.

Can be used to apply additional wall avoidance forces for example. Segments are formed by the obstacle vertex and its .next property.

Bug:
Always returns null
float ObstacleTimeHorizon
getset

Max number of estimated seconds to look into the future for collisions with obstacles.

Vector2 Position
getset

Position of the agent.

The agent does not move by itself, a movement script has to be responsible for reading the CalculatedTargetPoint and CalculatedSpeed properties and move towards that point with that speed. This property should ideally be set every frame.

The position is assumed to be at the base of the character (near the feet).

System.Action PreCalculationCallback
set

Callback which will be called right before avoidance calculations are started.

Used to update the other properties with the most up to date values

float Priority
getset

How strongly other agents will avoid this agent.

Usually a value between 0 and 1. Agents with similar priorities will avoid each other with an equal strength an agent with a much lower priority than another agent will avoid the other agent in a way similar to if the other agent was a moving obstacle.

float Radius
getset

Radius of the agent in world units.

Agents are modelled as circles/cylinders.


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