I’m sure I can throw something together fairly easily, but I figured I’d ask if there is a method that does this already.
Basically (instead of finding the nearest node to an object, that’s easy and not what I want), I want to find the nearest GameObject to a specific node. This is for a JobDispatch class, that hands out jobs to available NPCs. I don’t want NPCs being selected from across the map if I can avoid it. Of course, I’m not talking about near in terms of Vector3.Distance, I’m talking about pathfinding costs.
EDIT: trying to do something like this (this is returning null, however, and I know there are available agents):
That looks promising, something like this could work:
Vector3[] allPaths = new Vector3[_allAvailableAgents.Count];
for (int i = 0; i < _allAvailableAgents.Count; i++)
{
allPaths[i] = _allAvailableAgents[i].transform.position;
}
Path path = _seeker.StartMultiTargetPath((Vector3)position, allPaths, false, ParseMultiPath);
However, is there a built-in way to find out which path in the parameter allPaths it took (eg, which index)? Otherwise I think it’ll be better to just iterate over all my agents and use StartPath until I find the shortest (because then I’ll also have the associated agent, which is what I really want).
In any case it looks like I need to use Seeker.StartPath instead of just ABPath.Construct, so that’s helpful. Thank you.