A* Pathfinding Project  4.3.7
The A* Pathfinding Project for Unity 3D
RuleElevationPenalty Class Reference

Applies penalty based on the elevation of the node. More...

Detailed Description

Applies penalty based on the elevation of the node.

This is useful if you for example want to discourage agents from walking high up in mountain regions.

The penalty applied is equivalent to:

penalty = curve.evaluate(Mathf.Clamp01(Mathf.InverseLerp(lower elevation range, upper elevation range, elevation))) * penaltyScale
See also
Grid Graph Rules

Classes

struct  JobElevationPenalty
 

Public Member Functions

override void DisposeUnmanagedData ()
 Called when the rule is removed or the graph is destroyed. More...
 
override void Register (GridGraphRules rules)
 Does preprocessing and adds callbacks to the #GridGraphRules object. More...
 
- Public Member Functions inherited from GridGraphRule
virtual void SetDirty ()
 Call if you have changed any setting of the rule. More...
 

Public Attributes

AnimationCurve curve = AnimationCurve.Linear(0, 0, 1, 1)
 
Vector2 elevationRange = new Vector2(0, 100)
 
float penaltyScale = 10000
 
- Public Attributes inherited from GridGraphRule
bool enabled = true
 Only enabled rules are executed. More...
 
virtual int Hash => dirty
 Hash of the settings for this rule. More...
 

Private Attributes

NativeArray< float > elevationToPenalty
 

Additional Inherited Members

- Public Types inherited from GridGraphRule
enum  Pass { BeforeCollision, BeforeConnections, AfterConnections, PostProcess }
 Where in the scanning process a rule will be executed. More...
 
- Static Public Member Functions inherited from GridGraphRule
static void FilterNodeConnections< T > (IntRect bounds, NativeArray< int > nodeConnections, ref T filter)
 
static void ForEachNode< T > (IntRect bounds, ref T callback)
 

Member Function Documentation

◆ DisposeUnmanagedData()

override void DisposeUnmanagedData ( )
virtual

Called when the rule is removed or the graph is destroyed.

Use this to e.g. clean up any NativeArrays that the rule uses.

Note
The rule should remain valid after this method has been called. However the Register method is guaranteed to be called before the rule is executed again.

Reimplemented from GridGraphRule.

◆ Register()

override void Register ( GridGraphRules  rules)
virtual

Does preprocessing and adds callbacks to the #GridGraphRules object.

Reimplemented from GridGraphRule.

Member Data Documentation

◆ curve

AnimationCurve curve = AnimationCurve.Linear(0, 0, 1, 1)

◆ elevationRange

Vector2 elevationRange = new Vector2(0, 100)

◆ elevationToPenalty

NativeArray<float> elevationToPenalty
private

◆ penaltyScale

float penaltyScale = 10000

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