public void StartPathfinding()
 {
     print("Start pathfinding");
     if (!pathfinding)
     {
         pathfinding = GetComponent <Pathfinding>();
     }
     path = pathfinding.Dijkstra();
 }
Beispiel #2
0
    public Waypoint GetNearestWaypointToGoTo(Waypoint currentPos, Waypoint targetPos)
    {
        // We can't go to ourselves
        if (currentPos == targetPos)
        {
            return(null);
        }

        // Calculate and return the next point to go to
        Stack <Waypoint> path = Pathfinding.Dijkstra(waypointList, currentPos, targetPos);

        // A path was found...
        if (path != null && path.Count > 0)
        {
            return(path.Peek());
        }

        // There is no more places to go
        return(null);
    }