Skip to content

Commit

Permalink
Fix annoying navmesh agent exceptions
Browse files Browse the repository at this point in the history
  • Loading branch information
toberge committed Jul 12, 2024
1 parent d1c9bb0 commit 3f665ac
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions Assets/Scripts/Gamestate/AIManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,10 @@ private void FindPlayers()
agent.stoppingDistance = ShootingTarget ? shootingStoppingDistance : itemStoppingDistance;
try
{
agent.SetDestination(DestinationTarget.position);
if (agent.enabled)
agent.SetDestination(DestinationTarget.position);
else
aiMovement.enabled = true;
}
catch
{
Expand Down Expand Up @@ -287,7 +290,9 @@ IEnumerator AnimateJumpCurve(float duration)
normalizedTime += Time.deltaTime / duration;
yield return null;
}
agent.CompleteOffMeshLink();
// TODO why is the agent sometimes not enabled here?
if (agent.enabled)
agent.CompleteOffMeshLink();
onLinkEnd?.Invoke();
}

Expand Down

0 comments on commit 3f665ac

Please sign in to comment.