Skip to content

Instantly share code, notes, and snippets.

@DataGreed
Last active August 21, 2023 17:59
Show Gist options
  • Save DataGreed/df0c008be1f9269d5160af413e939843 to your computer and use it in GitHub Desktop.
Save DataGreed/df0c008be1f9269d5160af413e939843 to your computer and use it in GitHub Desktop.
Checks that NavMeshAgent reached destination or gave up trying
public bool ReachedDestinationOrGaveUp()
{
if (!_navMeshAgent.pathPending)
{
if (_navMeshAgent.remainingDistance <= _navMeshAgent.stoppingDistance)
{
if (!_navMeshAgent.hasPath || _navMeshAgent.velocity.sqrMagnitude == 0f)
{
return true;
}
}
}
return false;
}
@CarlZeidler
Copy link

Thanks, haven't done extensive testing yet but works well so far!

@behdadsoft
Copy link

Thanks.

@Demetree9
Copy link

You guys are awesome! Thanks for the code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment