A* Pathfinding Project  4.1.23
The A* Pathfinding Project for Unity 3D
AlternativePath Class Reference

Applies penalty to the paths it processes telling other units to avoid choosing the same path. More...

Detailed Description

Applies penalty to the paths it processes telling other units to avoid choosing the same path.

Note that this might not work properly if penalties are modified by other actions as well (e.g graph update objects which reset the penalty to zero). It will only work when all penalty modifications are relative, i.e adding or subtracting penalties, but not when setting penalties to specific values.

When destroyed, it will correctly remove any added penalty.

Public Member Functions

override void Apply (Path p)
 Called for each path that the Seeker calculates after the calculation has finished. More...
 
- Public Member Functions inherited from MonoModifier
virtual void PreProcess (Path path)
 

Public Attributes

int penalty = 1000
 How much penalty (weight) to apply to nodes. More...
 
int randomStep = 10
 Max number of nodes to skip in a row. More...
 
- Public Attributes inherited from MonoModifier
Seeker seeker
 

Protected Member Functions

void OnDestroy ()
 
- Protected Member Functions inherited from MonoModifier
virtual void OnDisable ()
 
virtual void OnEnable ()
 Alerts the Seeker that this modifier exists. More...
 
- Protected Member Functions inherited from VersionedMonoBehaviour
virtual void Awake ()
 
virtual int OnUpgradeSerializedData (int version, bool unityThread)
 Handle serialization backwards compatibility. More...
 
virtual void Reset ()
 Handle serialization backwards compatibility. More...
 

Properties

override int Order [get]
 
- Properties inherited from MonoModifier
abstract int Order [get]
 Modifiers will be executed from lower order to higher order. More...
 
- Properties inherited from IPathModifier
int Order [get]
 

Private Member Functions

void ApplyNow (List< GraphNode > nodes)
 
void ClearOnDestroy ()
 
void InversePrevious ()
 

Private Attributes

bool destroyed
 
List< GraphNodeprevNodes = new List<GraphNode>()
 The previous path. More...
 
int prevPenalty
 The previous penalty used. More...
 
readonly System.Random rnd = new System.Random()
 A random object. More...
 

Member Function Documentation

◆ Apply()

override void Apply ( Path  path)
virtual

Called for each path that the Seeker calculates after the calculation has finished.

Implements MonoModifier.

◆ ApplyNow()

void ApplyNow ( List< GraphNode nodes)
private

◆ ClearOnDestroy()

void ClearOnDestroy ( )
private

◆ InversePrevious()

void InversePrevious ( )
private

◆ OnDestroy()

void OnDestroy ( )
protected

Member Data Documentation

◆ destroyed

bool destroyed
private

◆ penalty

int penalty = 1000

How much penalty (weight) to apply to nodes.

◆ prevNodes

List<GraphNode> prevNodes = new List<GraphNode>()
private

The previous path.

◆ prevPenalty

int prevPenalty
private

The previous penalty used.

Stored just in case it changes during operation

◆ randomStep

int randomStep = 10

Max number of nodes to skip in a row.

◆ rnd

readonly System.Random rnd = new System.Random()
private

A random object.

Property Documentation

◆ Order

override int Order
get

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