- Home /
NavMesh Bake at Runtime
I want to use the in built 'NavMesh' by putting it onto my proceduraly generated terrain chunks which are made on Start(). I did some looking and found a github project and that did exactly what i wanted, that is by adding navmesh anywhere i wanted, however because the area the navmesh is needed in is fairly large this holds cpu usage in runtime at 100% which is not very practical...
I assume this is because the navmesh is being baked constantly but this is not needed as the terrain, once generated stays the same.
I am a beginner at this so any suggestions would be greatly appreciated.
Edit: I am using the scripts 'Local Nav Mesh Builder' and 'Nav Mesh Source Tag'.
Answer by Extiward · Mar 27, 2018 at 07:19 PM
I'm facing the same issue using LocalNavMeshBuilder and NavMeshSourceTag. I've come up with a flawed solution to add WaitForSeconds to the coroutine which bakes NavMesh in LocalNavMeshBuilder.cs:
IEnumerator Start()
{
while (true)
{
UpdateNavMesh(true);
yield return new WaitForSeconds(1);
yield return m_Operation;
}
}
In this case the delay is 1 second. With this I've gone from around 50% CPU usage on my machine to <1%, but each NavMesh update takes at least a second, which in my case is not critical. The wait time can be adjusted to suite your needs.
Alternatively you can call UpdateNavMesh function only when your world has updated.
Your answer
Follow this Question
Related Questions
NavMesh link with the terrain 1 Answer
Nav mesh holes with terrain 1 Answer
Terrain NavMesh bake 0 Answers
Navigation on over sized terrain 1 Answer
Non-NavMesh Enemy 0 Answers