Chazzmundo
New member
Hi, I have an issue where all of the NavMeshMovement based tasks (both existing and my own custom ones) are being restarted in the BT each frame which is causing the AI agents to stop moving, recalculate the NavMesh path and thus causing both performance issues as well as the AI agent to do "micro-stuttering" where it can only move a tiny amount each time due to the path being reset.
There's a hacky somewhat workaround to this by setting the AI agent acceleration to very high but I don't understand why
Here you can see the task being stopped (which therefore stops the agent and will restart the next frame)
The callstack triggering this removal being here (this is the part I can't work out what's going on and given it's compiled, I can't debug too much info out of it):

After this is stopped, the task will be started once again the very next frame and this issue will repeat.
Note that in this route, I'm returning `TaskStatus.Running` each frame so it's not due to what I'm sending back.
My BT looks like this:

The `Pursue Dynamic Target` is a custom task my end inheriting from `NavMeshMovement` but this also happens the exact same for inbuilt tasks like `Wander` (exists outside of the visible frame of this screenshot but has the same problem).
I've tried removing/changing the Abort Type all the way up the chain to the root thinking that may be the cause (I still don't get fully how this works to be honest and am sure I'm misusing this but it doesn't seem to properly re-evaluate anything without setting to it to `both` on pretty much everything).
One thing that may be relevant is that I do dynamically generate the NavMesh at runtime from time to time as the player moves around the world (it's an endless procedurally created 2D game). However, that's only happening once every few seconds at most based on how far the player moves from the last build point whereas this micro-stuttering caused by restarting the BT NavMeshMovement Tasks is happening much more commonly than that.
Any tips you can provide on how to prevent the tasks being cancelled and restarted each frame would be greatly appreciated!
There's a hacky somewhat workaround to this by setting the AI agent acceleration to very high but I don't understand why
Here you can see the task being stopped (which therefore stops the agent and will restart the next frame)

The callstack triggering this removal being here (this is the part I can't work out what's going on and given it's compiled, I can't debug too much info out of it):

After this is stopped, the task will be started once again the very next frame and this issue will repeat.
Note that in this route, I'm returning `TaskStatus.Running` each frame so it's not due to what I'm sending back.
My BT looks like this:

The `Pursue Dynamic Target` is a custom task my end inheriting from `NavMeshMovement` but this also happens the exact same for inbuilt tasks like `Wander` (exists outside of the visible frame of this screenshot but has the same problem).
I've tried removing/changing the Abort Type all the way up the chain to the root thinking that may be the cause (I still don't get fully how this works to be honest and am sure I'm misusing this but it doesn't seem to properly re-evaluate anything without setting to it to `both` on pretty much everything).
One thing that may be relevant is that I do dynamically generate the NavMesh at runtime from time to time as the player moves around the world (it's an endless procedurally created 2D game). However, that's only happening once every few seconds at most based on how far the player moves from the last build point whereas this micro-stuttering caused by restarting the BT NavMeshMovement Tasks is happening much more commonly than that.
Any tips you can provide on how to prevent the tasks being cancelled and restarted each frame would be greatly appreciated!


