Question about seeker.StartPath

Since the seeker.pathCallback is obsoleted, so I have to change the aiPath.SearchPath() to seeker.StartPath() with the callback passed as argument. I’ve read some code in the SearchPath() and see it run the below two lines before StartPath(),“waitingForPathCalculation” is a protected field, so should I override the AIPath to update it to true or Is there a code example to migrate the aiPath.SearchPath() to seeker.StartPath()?

waitingForPathCalculation = true;
seeker.StartPath(path, onPathComplete);

Is there a reason you cannot use ai.SetPath or ai.SearchPath?

you comment that I should use StartPath instead. if the seeker.pathCallback is not marked as obsoleted then I would not need to change to StartPath()

[System.Obsolete("Pass a callback every time to the StartPath method instead. You can cache it in your own script if you want to avoid the GC allocation of creating a new delegate.")]
public OnPathDelegate pathCallback;

I did see that you’ve mentioned I could use Update to poll the ai.pathPending, but it is a bit of complex in my project as I’m using Behavior Designer which means maybe I need to check it in most of my actions though I’ve not really thought into this solution as the callback would be more suitable and easy to me. And I did not see the callback could be passed by ai.SetPath or ai.SearchPath.

If you are using Behavior Designer, isn’t it very simple to use pathPending? You’d do something like this I guess:


using UnityEngine;
using BehaviorDesigner.Runtime;
using BehaviorDesigner.Runtime.Tasks;

public class CalculatePathAction : Action {

   public override void OnStart() {

   public override TaskStatus OnUpdate() {
      return ai.pathPending ? TaskStatus.Running : TaskStatus.Success;

Though I haven’t used Behavior Designer myself, so I’m not 100% sure how things work there.

After the path calculated, I need to check it if an error occur, which I get from seeker.GetCurrentPath(), Is it correct?

 public override TaskStatus OnUpdate()
            if (aiPath.pathPending)
                return TaskStatus.Running;

            var path = seeker.GetCurrentPath();
            if (path.error)
                // handle error
                // return ...

            return TaskStatus.Success;