If someone will search, then here is my solution:
NavMeshAgent _agent;
bool _hasPath;
public Action OnPointReached;
void Update()
{
if (_hasPath)
{
if(!_agent.hasPath)
{
_agent.isStopped = true; // For understanding - here the agent stops
OnPointReached?.Invoke(); // here we start an event or a function
}
else
{
_agent.isStopped = false; // The agent is moving
}
}
}
void LateUpdate()
{
_hasPath = _agent.hasPath;
}
The bottom line is that you need to duplicate the NavMeshAgent.hasPath value for the first check, but send it late - for this we assign the _hasPath value in LateUpdate. Roughly speaking: the agent will reach the destination, but the check will work again due to the fact that the value has not yet been updated, and inside we transfer the current value directly from the agent and get a single event firing.