AiPath.cs - Debug if path between Target and Seeker is true?

where in the AiPath example script can i throw a debug message if a path between Target and Seeker is valid?
since i am having sometimes something in the way(dynamic obstacle) between my player and the target and the path is not valid.

i thought it would be right here:
public virtual void OnPathComplete (Path _p) {
Debug.Log ("Yay, we got a path);

but that gets called even if the goal is not reached.
so something like is path possible. but i dont know how i can use this in the AiPath.cs example?
i already tried:

`public virtual void SearchPath () {
		if (!Pathfinding.PathUtilities.IsPathPossible (seeker,target)) {
			Debug.Log ("Yay, we got a path");

but that only throws out errors


This should do it

public virtual void OnPathComplete (Path _p) {
      if (_p.error) {
             Debug.Log("Target could not be reached");
      } else {
             Debug.Log("Target could be reached");

Note that if there is no path to the target it may try to find a path to a point close to the target. The maximum distance can be changed by modifying A* Inspector -> Settings -> Max Nearest Node Distance.

1 Like

works perfect now, thank you :slight_smile:

1 Like