Esempio n. 1
0
    public void GetGoalPosition()
    {
        UpdateStartPosition();
        StartNode = new Node2D(
            GridManager2D.Instance.GetGridCellCenter(GridManager2D.Instance.GetGridIndex(_startPos)));

        GoalNode = new Node2D(
            GridManager2D.Instance.GetGridCellCenter(GridManager2D.Instance.GetGridIndex(_player.transform.position)));

        _pathArray = AStar2D.FindPath(StartNode, GoalNode);
    }
Esempio n. 2
0
    private void GetGoalPosition(Vector2 startPosition)
    {
        StartNode = new Node2D(
            GridManager2D.Instance.GetGridCellCenter(GridManager2D.Instance.GetGridIndex(startPosition)));

        var mousePos = GetMouseInput();

        GoalNode = new Node2D(
            GridManager2D.Instance.GetGridCellCenter(GridManager2D.Instance.GetGridIndex(mousePos)));

        if (GoalNode.position.y < 1f)
        {
            GoalNode = StartNode;
        }
        _pathArray = AStar2D.FindPath(StartNode, GoalNode);
    }