A use I’ve found for A* in my game is not just pathfinding but also for finding locations to spawn objects. However not all nodes would be valid, e.g. a 10 unit sized object would not be suitable for a node with an erosion value of 1.
Is there some utility/method I’m missing somewhere in the API that allows me to find nodes by their erosion tag? If not, I’d probably have to make a dictionary and populate it with erosion tag->node relationships, but I can’t seem to find an event for when a graph/node is updated (so that I can keep the dictionary updated), is there one?
Hi
See A* Pathfinding Project
and also the erosionFirstTag field. Nodes which have a distance of 1 from the walls will have their tag set to erosionFirstTag+0, nodes with a distance of 2 from the wall will have their tag set to erosionFirstTag+1, etc. up to the erosion iterations value. The other nodes that were too far away will still have the default tag (0).
You can query the tag of a particular node using something like
var node = AstarPath.instance.GetNearest(somePosition, NNConstraint.None).node;
Debug.Log(node.Tag.ToString());
The NNConstraint can also be configured to prevent it returning nodes with some particular tags.
Sure, see A* Pathfinding Project