Setting targets - Use seeker.StartPath or AI Destination Setter

I am making a top-down 2D game and want to create a simple patrol between 4 points to get familiar with this package. I was following the get started tutorial, where it says to use seeker.StartPath(transform.position, targetPosition, OnPathComplete); to set a path. But then I read somewhere else that you should use the AI Destination Setter Component.

I tried using seeker.StartPath(transform.position, targetPosition, OnPathComplete); , But my character just ends up running in place ( a little bit backwards), even though the green line for his path is drawn correctly. It’s moving on the z-axis too which makes no sense because both for transform and target z = 0. If I move the character around when in play-mode it does move towards the green line sometimes, and other times it runs in place or backwards. Cant make any sense of it.
I would prefer to not swarm my scenes with Transform Targets so I would prefer to use this method of just putting in values. Is there something I could be missing? I simply copy+paste the first script from the get started tutorial.

AI destination setter it works as intended. I am OK using this if there was just some better docs on how to find out when a specific target is reached so I can do some action. And how to set new targets from script.

EDIT: Worth noting that the Debug.Log from OnPathComplete() is printed as soon as the scene starts. Without the path actually being complete.

Hi

The seeker.StartPath call you see there is from the part of the get started tutorial that talks about writing your own custom movement script. If you use the AIPath script which is included you do not have to do any of that.
You can use the AIDestinationSetter component which is a helper component for when your target is actually a transform. If you just want to move the agent to a point you can set AIPath.destination directly.

See https://arongranberg.com/astar/docs/iastarai.html#destination

GetComponent<AIPath>().destination = new Vector3(1, 2, 3);

OnPathComplete is called when the path has been calculated, it doesn’t have anything to do with if the AI has reached the end of the path or not. You can use ai.reachedEndOfPath or ai.reachedDestination.

1 Like