add 2nd solution for problem with long paths

This commit is contained in:
in0finite 2022-03-27 19:19:25 +02:00
parent d5a84e0c7f
commit 36306b4484

View file

@ -256,6 +256,19 @@ namespace SanAndreasUnity.Utilities
return;
}
// 2nd solution for problem above
float distanceTraveled = (myPosition - m_lastPositionWhenAssignedDestination.Value).magnitude;
if (currentTime - m_lastTimeWhenSearchedForPath > 3f
&& distanceTraveled > 200f
&& agent.pathStatus == NavMeshPathStatus.PathPartial)
{
Debug.Log($"re-path due to bug in NavMesh system #2 - agent {agent.name}, distanceTraveled {distanceTraveled}", this);
this.SetDestination();
return;
}
}
void SetDestination()