Skip to content

Commit

Permalink
When a Custom Agent is disabled, the correspoding Hidden agent is now…
Browse files Browse the repository at this point in the history
… set to inactive instead of getting destroyed. Upgraded the project to Unity version 2021.3.26f1 (LTS).
  • Loading branch information
jadvrodrigues committed Jun 1, 2023
1 parent 4db0e25 commit 9cd029b
Show file tree
Hide file tree
Showing 13 changed files with 5,310 additions and 3,860 deletions.
14 changes: 13 additions & 1 deletion Assets/CustomNavMesh/Scripts/CustomNavMeshAgent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -665,7 +665,7 @@ protected override void OnCustomDisable()
{
NavMeshAgent.enabled = false;

TryDestroyingHiddenAgent();
TryDisablingHiddenAgent();
}

protected override void OnCustomDestroy()
Expand Down Expand Up @@ -711,6 +711,18 @@ void TryCreatingHiddenAgent()
#endif
HiddenAgent.LinkWithCustomAgent(this);
}
else if(!HiddenAgent.gameObject.activeSelf)
{
HiddenAgent.gameObject.SetActive(true);
}
}

void TryDisablingHiddenAgent()
{
if (HiddenAgent != null)
{
HiddenAgent.gameObject.SetActive(false);
}
}

void TryDestroyingHiddenAgent()
Expand Down
2 changes: 1 addition & 1 deletion Assets/CustomNavMesh/Scripts/HiddenNavMeshAgent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ protected override void OnCustomEnable()
Agent.enabled = false;
}

protected override void OnCustomDisable()
protected override void OnCustomDestroy()
{
TryUnsubscribe();
}
Expand Down
2,854 changes: 1,427 additions & 1,427 deletions Assets/Examples/Scenes/1_multiple_agent_avoidance_after.unity

Large diffs are not rendered by default.

Loading

0 comments on commit 9cd029b

Please sign in to comment.