Need to know that a path has been i itialized

I am typing from phone.

My ai does this

Public void updatedelegate() //changes ai script update method

Walks.move(targetpos);.
If(istarai.reachedEndOfPath && executing == true)
{
Executing = false;
}

Easy easy, except not because astar does not immediately start calculating a new path, (and i dont want it to). So adding && !iastarai.pathpending does not work, because it has not even started yet, and may not for another .5 seconds, ( the update cycle i have it set to)

I need something like this

If(iastarai.hasreachedendofpath && iastarai.hasnopathcalculationqueued)
{
Executing = false;
}

So my ai can know it can dump the command and move to the next command in the list. I have tried a counter, to delay the check on iastarai.hasreachedendofpath, and it works, but i have to delay by .75 seconds to “work”, (my aistarai updates every .5 seconds), plus that causes a delay in the ai executing pother commands.

Isnt there a way for astar to say, “ok, i got the command for a new new path destination”. ?

Hi

I would recommend using ai.reachedDestination instead. It is updated immediately when you set ai.destination instead of being tied to when the path is recalculated.

Reacheddestination gives the same results

Figured it out. My walks.move(targetPos) indeed changed the target position, but this was not executed until update, meaning iastarai did not know the targetpos had changed to “immediately change iastarai.reacheddestination” until the next frame.

1 Like