예제 #1
0
 public void GetPath(Vector3 goal)
 {
     MyPath      = astar.Algorithm(transform.position, goal);
     current     = MyPath.Pop();
     destination = MyPath.Pop();
     this.goal   = goal;
 }
예제 #2
0
    public Queue <Vector3> GetWorldPath(Vector3 start, Vector3 goal)
    {
        Queue <Vector3> worldPath = new Queue <Vector3>();
        Vector3Int      startPos  = _Grid.Tilemap.WorldToCell(start);
        Vector3Int      goalPos   = _Grid.Tilemap.WorldToCell(goal);

        Stack <Vector3Int> path = _AStar.Algorithm(startPos, goalPos, _Grid);

        if (path != null)
        {
            foreach (Vector3Int pos in path)
            {
                Vector3 worldPos = _Grid.Tilemap.GetCellCenterWorld(pos);
                worldPath.Enqueue(worldPos);
            }
        }

        return(worldPath);
    }