Exemplo n.º 1
0
    protected void PathFind(int x, int y)
    {
        // Pathfind to player
        CellGrid cellGrid = LevelGen.CellGrid;

        GridCell targetCell  = cellGrid.Grid[x, y];
        GridCell currentCell = cellGrid.GetCellAtPos(transform.position);

        List <Vector3> path = cellGrid.FindPathWorld(targetCell, currentCell);

        if (path.Count > 1)
        {
            // Move towards next cell
            Vector3 dir = (path[1] - transform.position).normalized;
            TurnTowards(dir);
            Move(dir);
        }
    }