Exemplo n.º 1
0
    public List <Vector3> FindPath(Vector3 startPos, Vector3 endPos)
    {
        List <PathNode> path = FindPath(grid.GetXY(startPos), grid.GetXY(endPos));

        if (path == null)
        {
            return(null);
        }
        else
        {
            List <Vector3> vectorPath = new List <Vector3>();
            foreach (PathNode node in path)
            {
                Vector3 pathNode = new Vector3(node.x, node.y) * grid.GetCellSize() + Vector3.one * grid.GetCellSize() * 0.5f;
                vectorPath.Add(pathNode + grid.GetGridOrigin());
            }
            return(vectorPath);
        }
    }
 public Vector2Int GetGridXY(Vector3 worldPos)
 {
     return(grid.GetXY(worldPos));
 }