reset path if position can not be sampled

This commit is contained in:
in0finite 2022-03-20 21:57:46 +01:00
parent bc26a10ab5
commit 97f5dea402

View file

@ -218,8 +218,7 @@ namespace SanAndreasUnity.Utilities
m_lastTimeWhenSearchedForPath = Time.time;
m_lastAssignedDestination = this.Destination.Value;
m_lastPositionWhenAssignedDestination = navMeshAgent.transform.position;
this.CalculatedDestination = null;
// here we need to sample position on navmesh first, because otherwise agent will fail
// to calculate path if target position is not on navmesh, and as a result he will be stopped
@ -241,7 +240,9 @@ namespace SanAndreasUnity.Utilities
}
else
{
// TODO: reset agent's path
// if position can not be sampled, we stop the agent
navMeshAgent.ResetPath();
this.CalculatedDestination = null;
}
}