Grid Graph Rules
Contents
Overview
The GridGraph has a flexible system of rules that can be applied. These rules modify the nodes in various ways. For example a rule can apply a tag to a node based on the layer of the GameObject below the node, or it can apply a penalty to the node based on the slope of the surface.
You can add new rules by clicking the "Add Rule" button in the GridGraph inspector.
The available rules are
Penalty from slope angle
Penalty from elevation
Per layer modifications
Texture (set the penalty and walkability based on a texture)
Adding rules using a script
You can also add rules from a script:
// Get the first grid graph in the scene
var gridGraph = AstarPath.active.data.gridGraph;
gridGraph.rules.AddRule(new Pathfinding.Graphs.Grid.Rules.RuleAnglePenalty {
penaltyScale = 10000,
curve = AnimationCurve.Linear(0, 0, 90, 1),
});
Writing Custom Rules
If you want to write your own grid graph rules, then check out: Writing Custom Grid Graph Rules.