Navmesh Stop issue in Movement pack

EverAfter

New member
Hello! I'm having an issue thrown at me when unloading a scene with a NavMeshGroupMovement.
I noticed that NavMeshMovement has a check that makes it not throw the error for me with it.

/// <summary>
/// Stop pathfinding.
/// </summary>
protected override void Stop()
{
UpdateRotation(m_StartUpdateRotation);
if (m_NavMeshAgent.hasPath) {
m_NavMeshAgent.isStopped = true;
}
}

But with NavMeshGroupMovement it does not check NavMeshAgent.hasPath:
public override void OnEnd()
{
// Disable the nav mesh
for (int i = 0; i < m_NavMeshAgents.Length; ++i) {
if (m_NavMeshAgents != null) {
m_NavMeshAgents.isStopped = true;
}
}
}

Adding a NavMeshAgent.hasPath there for the group solved for me and it seems that this should be added in a patch considering that the NavMeshMovement already uses it. I don't like to change a plugin code directly, but in this case, I did not find another solution I'm requesting this. Does this make sense?
 
Sure, I can add that. I'm just curious - what version of Unity are you using? And what is the error?

Regardless I'll add that check since there's no harm even in previous Unity versions.
 
Hi Justin, the error I get is the following:

Code:
"Stop" can only be called on an active agent that has been placed on a NavMesh.
UnityEngine.StackTraceUtility:ExtractStackTrace ()
BehaviorDesigner.Runtime.Tasks.Movement.NavMeshGroupMovement:OnEnd () (at Assets/Behavior Designer Movement/Scripts/Tasks/NavMeshGroupMovement.cs:55)
BehaviorDesigner.Runtime.BehaviorManager:PopTask (BehaviorDesigner.Runtime.BehaviorManager/BehaviorTree,int,int,BehaviorDesigner.Runtime.Tasks.TaskStatus&,bool,bool)
BehaviorDesigner.Runtime.BehaviorManager:DestroyBehavior (BehaviorDesigner.Runtime.Behavior,BehaviorDesigner.Runtime.Tasks.TaskStatus)
BehaviorDesigner.Runtime.BehaviorManager:DisableBehavior (BehaviorDesigner.Runtime.Behavior,bool,BehaviorDesigner.Runtime.Tasks.TaskStatus)
BehaviorDesigner.Runtime.BehaviorManager:DisableBehavior (BehaviorDesigner.Runtime.Behavior,bool)
BehaviorDesigner.Runtime.Behavior:DisableBehavior ()
BehaviorDesigner.Runtime.Behavior:OnDisable ()


I'm using Unity version 2022.3.30f1.
The issue is happening when I'm reloading a scene. I have a queue task in a behavior, which I think is the NavMeshGroupMovement in question.
(I'm using multiple scenes so this may affect the setup somehow, did not managed to test in a clean project)
 
But the navmesh reference is only handled in the behavior tree task currently for me.
The Stop is being called via OnDisable of the Task. Therefore I suggested that the change to be done in the NavMeshGroupMovement just as it was done for the NavMeshMovement script. (That is what I've done currently, but since I plan to update the plugin in the future probably I would rather not modify it directly.)
 
Back
Top