Continuous update of the path

I need to have the path updated continuously when mouse0 is held down. The current setup with unity navmesh/agent is that I basically call :

navMeshAgent.CalculatePath(targetLocation, calculatedPath);

with GetMouseButton(0)

this gives me a continuously updated path and everything is dandy. If I however try and call AStar :

seeker.StartPath(transform.position, targetLocation, OnPathComplete);

it only updates the path when i release the mouse button. Am I missing something obvious here or?

Hi

This is because paths take some time to calculate, if you request a new path on a seeker before the previous one has been completely calculated, it will abort the previous one since it is very unlikely that you will need it, and start calculating the new one.
If you have path logging enabled (A* Inspector -> Settings -> Path Log Mode) you should get a warning for this.

Instead, either wait until you receive the results in OnPathComplete, or use seeker.IsDone ()

Cheers! Working like a charm now with just adding the StartPath to an if block:

if (seeker.IsDone())
{
seeker.StartPath(transform.position, targetLocation, OnPathComplete);
}

Also looks like there is a performance gain as well compared to the old. Awesomesauce! :slight_smile: