We will create the main function for setting the ambush path for all the agents and then the function for setting each agent's path:
- Define the main function for the ambush:
public void SetPathAmbush(GameObject dstObj, List<Lurker> lurkers) { Vertex dst = GetNearestVertex(dstObj.transform.position); foreach (Lurker l in lurkers) { Vertex src = GetNearestVertex(l.transform.position); l.path = AStarMbush(src, dst, l, lurkers); } }
- Declare the function for finding each path:
public List<Vertex> AStarMbush( Vertex src, Vertex dst, Lurker agent, List<Lurker> lurkers, Heuristic h = null) { // next steps }
- Declare the necessary members for handling the extra cost of computations:
int graphSize = vertices.Count; float[] extra ...