public List <Vector3> FindPath(Vector3 startPos, Vector3 endPos)
    {
        List <PathfindingNode> path = FindTarget(startPos, endPos);

        if (path == null)
        {
            return(null);
        }
        else
        {
            List <Vector3> worldPath = new List <Vector3>();
            foreach (PathfindingNode node in path)
            {
                worldPath.Add(new Vector3(node.GetX(), node.GetY()) * grid.GetCellSize() + Vector3.one * grid.GetCellSize());
            }
            return(worldPath);
        }
    }
Beispiel #2
0
 private int CalculateDistanceCost(PathNode a, PathNode b)
 {
     return((int)pathGrid.GetCellSize() * (Mathf.Abs(a.x - b.x) + Mathf.Abs(a.y - b.y)));
 }