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(); } }
void FindPath() { start = NodeManager.Instance.NearestNode(this.gameObject); goal = NodeManager.Instance.NearestNode(target.gameObject); path = pathFinder.AStarPath(start, goal); }