A* Pathfinding Project
3.8.6
The A* Pathfinding Project for Unity 3D
|
RVO Character Controller. More...
RVO Character Controller.
Designed to be used as a drop-in replacement for the Unity Character Controller, it supports almost all of the same functions and fields with the exception that due to the nature of the RVO implementation, desired velocity is set in the Move function and is assumed to stay the same until something else is requested (as opposed to reset every frame).
For documentation of many of the variables of this class: refer to the Pathfinding.RVO.IAgent interface.
Public Member Functions | |
void | Awake () |
void | Move (Vector3 vel) |
Set the desired velocity for the agent. | |
void | OnDisable () |
void | OnDrawGizmos () |
void | OnEnable () |
void | Teleport (Vector3 pos) |
Teleport the agent to a new position. | |
void | Update () |
Public Attributes | |
float | agentTimeHorizon = 2 |
How far in the time to look for collisions with other agents. | |
Vector3 | center |
Center of the agent relative to the pivot point of this game object. | |
RVOLayer | collidesWith = (RVOLayer)(-1) |
Layer mask specifying which layers this agent will avoid. | |
bool | debug |
bool | enableRotation = true |
float | height = 1 |
Height of the agent. | |
RVOLayer | layer = RVOLayer.DefaultAgent |
Specifies the avoidance layer for this agent. | |
bool | locked |
A locked unit cannot move. | |
bool | lockWhenNotMoving = true |
Automatically set locked to true when desired velocity is approximately zero. | |
LayerMask | mask = -1 |
Layer mask for the ground. | |
int | maxNeighbours = 10 |
Max number of other agents to take into account. | |
float | maxSpeed = 2 |
Max speed of the agent. | |
float | neighbourDist = 10 |
Maximum distance to other agents to take them into account for collisions. | |
float | obstacleTimeHorizon = 2 |
How far in the time to look for collisions with obstacles. | |
float | radius = 5 |
Radius of the agent. | |
float | rotationSpeed = 30 |
IAgent | rvoAgent |
Reference to the internal agent. | |
float | wallAvoidFalloff = 1 |
How much the wallAvoidForce decreases with distance. | |
float | wallAvoidForce = 1 |
An extra force to avoid walls. | |
Protected Member Functions | |
void | UpdateAgentProperties () |
Properties | |
Vector3 | position [get] |
Current position of the agent. | |
Vector3 | velocity [get] |
Current velocity of the agent. | |
Private Attributes | |
float | adjustedY |
Vector3 | desiredVelocity |
Current desired velocity. | |
Vector3 | lastPosition |
Position for the previous frame. | |
Simulator | simulator |
Reference to the rvo simulator. | |
Transform | tr |
Cached tranform component. | |
Static Private Attributes | |
static RVOSimulator | cachedSimulator |
To avoid having to use FindObjectOfType every time. | |
static readonly Color | GizmoColor = new Color(240/255f, 213/255f, 30/255f) |
void Awake | ( | ) |
void Move | ( | Vector3 | vel | ) |
Set the desired velocity for the agent.
Note that this is a velocity (units/second), not a movement delta (units/frame).
void OnDisable | ( | ) |
void OnDrawGizmos | ( | ) |
void OnEnable | ( | ) |
void Teleport | ( | Vector3 | pos | ) |
Teleport the agent to a new position.
The agent will be moved instantly and not show ugly interpolation artifacts during a split second. Manually changing the position of the transform will in most cases be picked up as a teleport automatically by the script.
During the simulation frame the agent was moved manually, local avoidance cannot fully be applied to the agent, so try to avoid using it too much or local avoidance quality will degrade.
void Update | ( | ) |
|
protected |
|
private |
float agentTimeHorizon = 2 |
How far in the time to look for collisions with other agents.
|
staticprivate |
To avoid having to use FindObjectOfType every time.
Vector3 center |
Center of the agent relative to the pivot point of this game object.
Layer mask specifying which layers this agent will avoid.
You can set it as CollidesWith = RVOLayer.DefaultAgent | RVOLayer.Layer3 | RVOLayer.Layer6 ...
This can be very useful in games which have multiple teams of some sort. For example you usually want that the team agents avoid each other, but you do not want them to avoid the enemies.
bool debug |
|
private |
Current desired velocity.
bool enableRotation = true |
|
staticprivate |
float height = 1 |
Height of the agent.
In world units
|
private |
Position for the previous frame.
Used to check if the agent has moved manually
RVOLayer layer = RVOLayer.DefaultAgent |
Specifies the avoidance layer for this agent.
The collidesWith mask on other agents will determine if they will avoid this agent.
bool locked |
A locked unit cannot move.
Other units will still avoid it. But avoidance quailty is not the best.
bool lockWhenNotMoving = true |
Automatically set locked to true when desired velocity is approximately zero.
This prevents other units from pushing them away when they are supposed to e.g block a choke point.
LayerMask mask = -1 |
Layer mask for the ground.
The RVOController will raycast down to check for the ground to figure out where to place the agent.
int maxNeighbours = 10 |
Max number of other agents to take into account.
A smaller value can reduce CPU load, a higher value can lead to better local avoidance quality.
float maxSpeed = 2 |
Max speed of the agent.
In units/second
float neighbourDist = 10 |
Maximum distance to other agents to take them into account for collisions.
Decreasing this value can lead to better performance, increasing it can lead to better quality of the simulation.
float obstacleTimeHorizon = 2 |
How far in the time to look for collisions with obstacles.
float radius = 5 |
Radius of the agent.
float rotationSpeed = 30 |
IAgent rvoAgent |
Reference to the internal agent.
|
private |
Reference to the rvo simulator.
|
private |
Cached tranform component.
float wallAvoidFalloff = 1 |
How much the wallAvoidForce decreases with distance.
The strenght of avoidance is:
float wallAvoidForce = 1 |
An extra force to avoid walls.
This can be good way to reduce "wall hugging" behaviour.
|
get |
Current position of the agent.
|
get |
Current velocity of the agent.