A* Pathfinding Project  4.3.5
The A* Pathfinding Project for Unity 3D
RVODestinationCrowdedBehavior Struct Reference

Controls if the agent slows down to a stop if the area around the destination is crowded. More...

Detailed Description

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

  • Reduce the local avoidance priority for agents that have reached their destination once.
  • Make agents stop if there is a high density of units around its destination.

'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.

See also
Pathfinding.AIBase.rvoDensityBehavior

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

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...
 

Constructor & Destructor Documentation

◆ RVODestinationCrowdedBehavior()

RVODestinationCrowdedBehavior ( bool  enabled,
float  densityFraction,
bool  returnAfterBeingPushedAway 
)

Member Function Documentation

◆ OnDestinationChanged()

void OnDestinationChanged ( Vector3  newDestination,
bool  reachedDestination 
)

◆ ReadJobResult()

void ReadJobResult ( ref JobDensityCheck  jobResult,
int  index 
)

◆ Update()

void Update ( bool  reachedDestination,
out bool  isStopped,
ref float  rvoPriorityMultiplier,
ref float  rvoFlowFollowingStrength 
)

Member Data Documentation

◆ DefaultPriority

const float DefaultPriority = 1.0f

◆ densityThreshold

float densityThreshold

The threshold for when to stop.

See the class description for more info.

◆ enabled

bool enabled

Enables or disables this module.

◆ lastShouldStopResult

bool lastShouldStopResult

◆ MaximumCirclePackingDensity

const float MaximumCirclePackingDensity = 0.9069f

◆ MoveBackPriority

const float MoveBackPriority = 0.5f

◆ returnAfterBeingPushedAway

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.

◆ shouldStopDelayTimer

float shouldStopDelayTimer

◆ StoppedPriority

const float StoppedPriority = 0.1f

◆ timer1

float timer1

◆ wasEnabled

bool wasEnabled

Property Documentation

◆ reachedDestination

bool reachedDestination
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.

See also
Pathfinding.IAstarAI.destination

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