A* Pathfinding Project
4.3.5
The A* Pathfinding Project for Unity 3D
|
Controls if the agent slows down to a stop if the area around the destination is crowded. More...
Controls if the agent slows down to a stop if the area around the destination is crowded.
The main idea for this script is to
'High density' is defined as: Take the circle with the center at the AI's destination and a radius such that the AI's current position is touching its border. Let 'A' be the area of that circle. Further let 'a' be the total area of all individual agents inside that circle. The agent should stop if a > A*0.6 or something like that. I.e if the agents inside the circle cover over 60% of the surface of the circle. The 60% figure can be modified (see densityThreshold).
This script was inspired by how Starcraft 2 does its local avoidance.
Classes | |
struct | JobDensityCheck |
Public Member Functions | |
RVODestinationCrowdedBehavior (bool enabled, float densityFraction, bool returnAfterBeingPushedAway) | |
void | OnDestinationChanged (Vector3 newDestination, bool reachedDestination) |
void | ReadJobResult (ref JobDensityCheck jobResult, int index) |
void | Update (bool reachedDestination, out bool isStopped, ref float rvoPriorityMultiplier, ref float rvoFlowFollowingStrength) |
Public Attributes | |
const float | DefaultPriority = 1.0f |
float | densityThreshold |
The threshold for when to stop. More... | |
bool | enabled |
Enables or disables this module. More... | |
bool | lastShouldStopResult |
const float | MaximumCirclePackingDensity = 0.9069f |
See https://en.wikipedia.org/wiki/Circle_packing. More... | |
const float | MoveBackPriority = 0.5f |
bool | returnAfterBeingPushedAway |
If true, the agent will start to move to the destination again if it determines that it is now less crowded. More... | |
float | shouldStopDelayTimer |
const float | StoppedPriority = 0.1f |
float | timer1 |
bool | wasEnabled |
Properties | |
bool | reachedDestination [get, private set] |
True if the agent has reached its destination. More... | |
RVODestinationCrowdedBehavior | ( | bool | enabled, |
float | densityFraction, | ||
bool | returnAfterBeingPushedAway | ||
) |
void OnDestinationChanged | ( | Vector3 | newDestination, |
bool | reachedDestination | ||
) |
void ReadJobResult | ( | ref JobDensityCheck | jobResult, |
int | index | ||
) |
void Update | ( | bool | reachedDestination, |
out bool | isStopped, | ||
ref float | rvoPriorityMultiplier, | ||
ref float | rvoFlowFollowingStrength | ||
) |
const float DefaultPriority = 1.0f |
float densityThreshold |
The threshold for when to stop.
See the class description for more info.
bool enabled |
Enables or disables this module.
bool lastShouldStopResult |
const float MaximumCirclePackingDensity = 0.9069f |
const float MoveBackPriority = 0.5f |
bool returnAfterBeingPushedAway |
If true, the agent will start to move to the destination again if it determines that it is now less crowded.
If false and the destination becomes less crowded (or if the agent is pushed away from the destination in some way), then the agent will still stay put.
float shouldStopDelayTimer |
const float StoppedPriority = 0.1f |
float timer1 |
bool wasEnabled |
|
getprivate set |
True if the agent has reached its destination.
If the agents destination changes this may return false until the next frame. Note that changing the destination every frame may cause this value to never return true.
True will be returned if the agent has stopped due to being close enough to the destination. This may be quite some distance away if there are many other agents around the destination.