Interface ITraversalProvider

Public

Provides additional traversal information to a path request.

Example implementation: public class MyCustomTraversalProvider : ITraversalProvider {
public bool CanTraverse (Path path, GraphNode node) {
// Make sure that the node is walkable and that the 'enabledTags' bitmask
// includes the node's tag.
return node.Walkable && (path.enabledTags >> (int)node.Tag & 0x1) != 0;
// alternatively:
// return DefaultITraversalProvider.CanTraverse(path, node);
}

public bool CanTraverse (Path path, GraphNode from, GraphNode to) {
return CanTraverse(path, to);
}
public uint GetTraversalCost (Path path, GraphNode node) {
// The traversal cost is the sum of the penalty of the node's tag and the node's penalty
return path.GetTagPenalty((int)node.Tag) + node.Penalty;
// alternatively:
// return DefaultITraversalProvider.GetTraversalCost(path, node);
}

// This can be omitted in Unity 2021.3 and newer because a default implementation (returning true) can be used there.
public bool filterDiagonalGridConnections {
get {
return true;
}
}
}

Public Methods

CanTraverse (path, node)

True if node should be able to be traversed by the path.

Public
CanTraverse (path, from, to)

True if the path can traverse a link between from and to and if to can be traversed itself.

Public
GetTraversalCost (path, node)

Cost of traversing a given node.

Public

Public Variables

filterDiagonalGridConnections

Filter diagonal connections using GridGraph.cutCorners for effects applied by this ITraversalProvider.

Public