A* Pathfinding Project

The seeker start to move when call StartPath()?


#1

Sorry for stupid noob question.

I expect the function StartPath() is just to find out the available path for seeker.

But when I call startpath(), the seeker object start moving. Shouldn’t it stay at where it is?


#2

Hey,

The value isStopped is by default false. So aslong as canMove is enabled the agent will move as soon as it’s able to.

https://arongranberg.com/astar/docs/aibase.html#isStopped


StartPath() do not update Astar Path in same frame?
#3

I have set canMove to be false, so StartPath() will reset canMove to true automatically?

My game is turn based chess, I think canMove is much better than isstopped, because I don’t need the path caculation all the time.


#4

Nope

Seeker.StartPath() only calculates a path.
The AI will take care of the actual movement.


#5

Hi

The AIPath script (and other movement scripts) listen to paths completed on the Seeker and use those results.

If you want to calculate a path completely separately from the seeker you can do this:

var path = ABPath.Construct(startPoint, endPoint, OnPathComplete);
AstarPath.StartPath(path);

void OnPathComplete(Path path) {
    // Optionally if you want to use the path modifiers attached to the Seeker
    seeker.PostProcess(path);
    // Do whatever with the path
    // You can for example use ai.SetPath(path) to make a movement script follow it
}

See https://arongranberg.com/astar/docs/callingpathfinding.html for more info