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 6b1ffeb
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions Assets/Scripts/Gamestate/AIManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,8 @@ private void FindPlayers()
agent.stoppingDistance = ShootingTarget ? shootingStoppingDistance : itemStoppingDistance;
try
{
agent.SetDestination(DestinationTarget.position);
if (agent.enabled)
agent.SetDestination(DestinationTarget.position);
}
catch
{
Expand Down Expand Up @@ -287,7 +288,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 6b1ffeb

Please sign in to comment.