When my bomb hits the terrain, it creates a hole, and everything works, but the NavMesh still uses the old terrain. I tried to bake the terrain when the bomb explodes, but it freezes for 3 seconds and then continues. I couldn’t find any solution. I don’t understand why it seems like no one has tried this; it’s such an important function to update during runtime.
What about using a Task in order to avoid blocking the main thread?
Task.Run(() =>
{
// Represents a Performance Intensive Method like some pathfinding or really complex calculation. This code won't run on the Main Thread!
float value = 0f;
for (int i = 0; i < timesToRepeat; i++)
{
value = math.exp10(math.sqrt(value));
}
});
Baking the navmesh is done by Unity function, putting it in a task doesn’t work. It’s already multithreaded, just not in the way that it works properly.
How big is your navigation mesh?
A solution would probably be to make it smaller and work with different nav mesh surfaces, which you need to stitch together with NavMeshLinks.
Thanks for your answer i just created a script that bakes Navmesh using the Navmesh Surface settings dont know why there wasnt a Script allready in it but yeah.
Thank you so much for helping
– felixklein460