Example #1
0
    void FindPath()
    {
        if (DistanceToTarget() < 1f)
        {
            bt.FinishFailure();
        }
        Node start = NodeManager.Instance.NearestNode(gameObject);
        Node goal  = NodeManager.Instance.NearestNode(target.gameObject);

        path = pf.AStarPath(start, goal);
        // AStarPath returns null when no path found
        if (path != null)
        {
            bt.FinishSuccess();
        }
        else
        {
            bt.FinishFailure();
        }
    }
Example #2
0
 void FindPath()
 {
     start = NodeManager.Instance.NearestNode(this.gameObject);
     goal  = NodeManager.Instance.NearestNode(target.gameObject);
     path  = pathFinder.AStarPath(start, goal);
 }