I am trying to get if the ai has reached the target, but it is not working.
reachedEndOfPath & reachedDestination are allways false, and aIPath.remainingDistance <= aIPath.endReachedDistance is not working, becase remainingDistance is returning high values when close to destination.
I am setting this like:
path = GenerateRandomPath(spread);
aIPath.maxSpeed = UnityEngine.Random.Range(minSpeed, maxSpeed);
aIPath.enabled = true;
aIPath.SetPath(path);
aIPath.canMove = true;
StartCoroutine(ReachedDestination());
protected IEnumerator ReachedDestination()
{
while (!aIPath.reachedEndOfPath || !aIPath.reachedDestination || aIPath.remainingDistance <= aIPath.endReachedDistance)
{
yield return null;
}
print("Destination reached");
rVOController.locked = true;
aIPath.enabled = false;
}