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();
}
}