Correct implemention of GetNearest & IsPathPossible(nodeList, tagMask) question

Hi,

I’ve been playing with these and threw this together. Is this a correct usage? As in, would the slowness of the IsPathPossible method significantly reduce performance with, say, 50 agents?

The use case involves locking, unlocking doors depending on the agent.

Code example:

 if (Input.GetMouseButtonDown(1))
            {
                if (Physics.Raycast(Camera.main.ScreenPointToRay(Input.mousePosition), out RaycastHit hit, Mathf.Infinity, groundLayer))
                {
                    Vector3 unitDestinationPoint = hit.point;
                   
                    GraphNode node1 = AstarPath.active.GetNearest(transform.position, NNConstraint.Default).node;
                    GraphNode node2 = AstarPath.active.GetNearest(unitDestinationPoint, NNConstraint.Default).node;
                    unitDestinationPoint = (Vector3)node2.position;

                    List<GraphNode> nodes = new List<GraphNode>();
                    nodes.Add(node1);
                    nodes.Add(node2);
                    int tagmask = GetComponent<Agent_Basic>().tagMask;

                    if (PathUtilities.IsPathPossible(nodes, tagmask))
                    {
                        foreach (GameObject unit in sel.selectedAgents)
                        {
                            unit.GetComponent<AIDestinationSetter>().target.transform.position = unitDestinationPoint;

                            unit.GetComponent<Agent_Get_Moved>().enabled = true;
                        }
                    }
                    else
                    {
                        Debug.Log("Path is not possible!");
                    }
                }
                else
                {
                    sel.ClearSelection();
                }
            }

Hi

From what I can see the IsPathPossible call is only done once, regardless of how many agents you have?

If you are using a tag mask it may be faster to do a path request for each agent and see if it reached a sufficiently close point to the target.