Turn-Based Grid Difficulties

Nice to see that you are making progress.
Finding the nearest node using an ITraversableProvider isn’t possible. To modify the get nearest you can make use of the NNConstant. https://arongranberg.com/astar/docs/class_pathfinding_1_1_n_n_constraint.php

Here is an example custom constraint with the addition of a blocked node list.

public class CustomPathNNConstraint : PathNNConstraint
	{
		private HashSet<GraphNode> blockedNodes;
		
		public new static CustomPathNNConstraint Default =>
			new CustomPathNNConstraint {
				constrainArea = true
			};

		public virtual void SetBlockedNodes(HashSet<GraphNode> nodes)
		{
			blockedNodes = nodes;
		}
		
		public override bool Suitable (GraphNode node) {			
			if (!base.Suitable(node)) return false;

			if (blockedNodes != null && blockedNodes.Contains(node))
                        return false;

			return true;
		}
	}
2 Likes