Search Unity

Bad FPS spikes with NavMesh building at runtime

Discussion in 'Navigation' started by JohnTomorrow, Aug 12, 2017.

  1. JohnTomorrow

    JohnTomorrow

    Joined:
    Apr 19, 2013
    Posts:
    135
    Hey was wondering what can be done about FPS spikes when rebuilding a navmesh at runtime. When the meshes are built there is a horrible spike in the Camera.Render in the NavMesh.TileMesh call (greater than 200ms). I am building a graph 200x200x200 around the player as any smaller would be pretty useless. I have cached all the sources which hugely fixed all the other performance problems. Any insight in what the engine is doing or any plans to optimize this further on the engine side? Would really like to roll this feature out in our live game but this is kinda a deal breaker.
     

    Attached Files:

    RobinHut3 likes this.
  2. JohnTomorrow

    JohnTomorrow

    Joined:
    Apr 19, 2013
    Posts:
    135
    Overwrote some of the navmesh settings and it has seemed to help a lot.

    Code (CSharp):
    1.  defaultBuildSettings.overrideVoxelSize = true;
    2. defaultBuildSettings.voxelSize = 0.25f;
    3. defaultBuildSettings.overrideTileSize = true;
    4. defaultBuildSettings.tileSize = 64;
    This should probably be part of the example code...
     
    RobinHut3, malkere and christougher like this.
  3. malkere

    malkere

    Joined:
    Dec 6, 2013
    Posts:
    1,212
    It was the tile size for me. I had Director.PreFrameProcess or something like that WaitForJob pulling 200ms. Put my tile size to 100 (my meshes at 102.5 procedural tiles) got rid of it entirely. Not sure what it was at by default, but I had called an unset agentID once and it returned -892674 so... best to set everything manually if you're doing it through script
     
    RobinHut3 likes this.