Function AstarPath.StartPath

StartPath (Path path, bool pushToFront=…, bool assumeInPlayMode=…)

Adds the path to a queue so that it will be calculated as soon as possible.

Public Static
void StartPath (

Path

path

The path that should be enqueued.

bool

pushToFront=false

If true, the path will be pushed to the front of the queue, bypassing all waiting paths and making it the next path to be calculated. This can be useful if you have a path which you want to prioritize over all others. Be careful to not overuse it though. If too many paths are put in the front of the queue often, this can lead to normal paths having to wait a very long time before being calculated.

bool

assumeInPlayMode=false

Typically path.BlockUntilCalculated will be called when not in play mode. However, the play mode check will not work if you call this from a separate thread, or a job. In that case you can set this to true to skip the check.

)

Adds the path to a queue so that it will be calculated as soon as possible.

The callback specified when constructing the path will be called when the path has been calculated. Usually you should use the Seeker component instead of calling this function directly.

// There must be an AstarPath instance in the scene
if (AstarPath.active == null) return;

// We can calculate multiple paths asynchronously
for (int i = 0; i < 10; i++) {
var path = ABPath.Construct(transform.position, transform.position+transform.forward*i*10, OnPathComplete);

// Calculate the path by using the AstarPath component directly
AstarPath.StartPath(path);
}