NavMeshBuilder invalidates NavMeshAgent paths
I've started using NavMeshComponents to continuously bake updating navmeshes, all of this works fine. But for my NavMeshAgents they seem to have their paths invalidated when the bake finishes, they then recalculate paths automatically but this causes them to stop moving until their new path is ready.
Question: Is there a way for me to bake a NavMesh without invalidating my agent's paths? The perfect solution would be they continue using their "out-of-date" path until the new path is calculated.
Answer by Hidrem · Apr 02, 2018 at 05:11 AM
If I understand correctly, you are wanting navmeshagents to update their navmesh's in real time? If so I suggest watching this tutorial : https://youtu.be/FkLJ45Pt-mY
I did learn something from the video you linked, but it didn't answer the question. Agents are generating paths from an existing navmesh, that navmesh is updated/baked/recalculated with new geometry and when it does this all the agents which were currently following paths have their paths invalidated and stop.
The big desire here is to use the async capabilities of agent pathfinding and navmeshbuilder to not block the game's update loop, but currently the model is causing agent stuttering.
I'm just going to go with the Nav$$anonymous$$eshObstacles from the video you linked, I suppose the answer to my question is "you cannot and you shouldn't try". I'll just need to find gameplay ways to hide the times when I need a full Nav$$anonymous$$esh rebake.
Thank you for the video link Hidrem.
Answer by duzbot · Apr 29, 2018 at 08:32 PM
hi @adamzl, I think i am suffering with the same problem.
here's a link to a video record of my particular situation https://www.youtube.com/watch?v=qLm3vIWTRNc
As you can see from what i'm trying to achieve with the revolving maze idea, a NavMeshObstacle won't do the job...
Just thought I'd share this with you and if you had any thoughts.,Hi @adamzl, I think i am suffering with the same problem.
Just to add...
for some reason if I add an empty gameobject with a Nav$$anonymous$$eshLink component with no proper use, then the problem seems to go away for about a $$anonymous$$ute before the N$$anonymous$$A stops moving again. Seems a bit random why this offers a brief fix
You should write the Nav$$anonymous$$eshAgent.destination every update, that'll probably fix your issue.
I'll have to dig into the AI pathfinding script i've borrowed to check if it is or isn't doing that. Thanks for the tip.
Did you come to a fix or a solution to your original problem in the end?
Answer by adamzl · Apr 30, 2018 at 06:14 PM
The fix for me was to stop using NavMeshes incorrectly. Anything that could change the NavMesh while agents were moving on the mesh had to be an NavMeshObstacle. The whole runtime calculation of nav meshes from geometry seems to only be useful if you're willing to bake before agents start using it and never again, mostly useful for run-time generated geometry.
Your answer
Follow this Question
Related Questions
Is there anyway to avoid a StackOverflow 0 Answers
NavMeshAgent not teleport on y axis 0 Answers
NavMesh agent pushed by bullet 0 Answers
How do I change my NavMesh Agent from one NavMesh to another? 0 Answers