There's more...

This time, we will need to implement a different BuildPath function, in case you have followed along with the previous path-finding recipes. Otherwise, we will need to implement this method, which we haven't defined yet:

private List<Vertex> BuildPath(Vertex v) 
{ 
    List<Vertex> path = new List<Vertex>(); 
    while (!ReferenceEquals(v, null)) 
    { 
        path.Add(v); 
        v = v.prev; 
    } 
    return path; 
} 

Get Unity 2018 Artificial Intelligence Cookbook - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.