Function TraversalProvider.CanTraverse

CanTraverse (refTraversalConstraint traversalConstraint, GraphNode node)

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

Public
bool CanTraverse (

refTraversalConstraint

traversalConstraint

Full constraint that this traversal provider is part of. You can use this to check additional nodes using TraversalConstraint.CanTraverseSkipUserFilter(GraphNode). It is passed by reference to avoid the performance cost of copying it, since this method is quite hot.

GraphNode

node

The node to check. Should not be null.

)

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

If you are implementing a custom ITraversalProvider, you should override this method and do whatever checks you need to do to determine if the node is traversable.

When used, the ITraversalProvider will pretty much always be wrapped in a TraversalConstraint struct. The TraversalConstraint.CanTraverse(GraphNode) method will then do its own checks first, and call this method to do additional filtering. This means that the ITraversalProvider is always at least as strict as the TraversalConstraint.

Note

This also means that returning true from this method does not necessarily mean that the node is traversable by a path. The TraversalConstraint may have additional filters, and in particular it always checks that the node is walkable.

public bool CanTraverse (ref TraversalConstraint traversalConstraint, GraphNode node) {
// If, for example, your agents are afraid of heights, prevent your agents from going above 50 world units
return ((Vector3)node.position).y < 50;
}