Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

[Closed] Dynamic Navmesh has bad Performance on VoxelTerrain

Discussion in 'Navigation' started by John_Leorid, Dec 9, 2018.

  1. John_Leorid

    John_Leorid

    Joined:
    Nov 5, 2012
    Posts:
    646
    Hello,
    I am using a Marching Cubes Voxel World and I tried using Unitys new Dynamic-Navmesh System, but it lags. Picture attached: what does this Deep Profiling tell me?

    How can I improve the performance? Is there any way to "calm down" the Garbage Collection? (which I think is the cause of the lag)

    Thanks in Advice,
    Leorid
     

    Attached Files:

  2. Yandalf

    Yandalf

    Joined:
    Feb 11, 2014
    Posts:
    491
    I'm afraid we're going to need more information to be of help, only thing we can conclude here is that your GC is indeed off the rocker.
    Can you run this again and look at exactly what parts of your application are generating this much garbage? The number one way to calm down GC is by simply producing less, so your code probably can use a ton of optimization.
     
  3. John_Leorid

    John_Leorid

    Joined:
    Nov 5, 2012
    Posts:
    646
    Well it's not my code, it's unitys pathfinding code. The Ultimate Terrain Scene works perfectly until I put in the Unity dynamic pathfinding prefab, which I took exactly from the examples.
    I can't even see the Code, nor change it.
     
  4. Yandalf

    Yandalf

    Joined:
    Feb 11, 2014
    Posts:
    491
    Okay, just to be sure you should profile again and take a detailed look at what classes and methods are exactly generating all that garbage.
    That said, it could very well be that Ultimate Terrain keeps expanding and updating all the time, forcing recalculations of the NavMesh. While Unity's NavMesh system is actually decent at filtering out unnecessary regions for recalculation, it might simply not be built to be used within this scale. You might have to look for a NavMesh solution that only calculates the immediate area around the player.
     
  5. John_Leorid

    John_Leorid

    Joined:
    Nov 5, 2012
    Posts:
    646
    Ok, I'll try different things, but is there any advice if it's better to have for like 15 enemies on bigger dynamic navmesh generator or one for each enemy but slightly smaller? Or won't this affect performance at all? - also I could try generating my own Mesh just for pathfinding, which won't change all the time - and yes, Ultimate Terrains keeps updating Meshes all the Time based on player distance, so theres the best possible amount vertices near the player.
     
  6. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    Need to stop guessing and report what allocates exactly, from the profiler. Your screenshot does not show this because you never selected hierarchical display. Simply enabling profiler isn't using profiler.
     
  7. John_Leorid

    John_Leorid

    Joined:
    Nov 5, 2012
    Posts:
    646
    "selected hierarchical display." Ok I'll do this asap. Maybe I should have watched a tutorial on how to use the profiler right..
     
  8. Yandalf

    Yandalf

    Joined:
    Feb 11, 2014
    Posts:
    491
    Yeah, the profiler is honestly not that difficult to use once you know what info you can get out of it and how to use it.
    Update us once you have a detailed view.
     
  9. John_Leorid

    John_Leorid

    Joined:
    Nov 5, 2012
    Posts:
    646
    I think I got it wrong, the navmesh actually works good and the huge amount of garbage was because of other things, I am not 100% sure, because the whole setup of my scene changed and this issue is gone.
    Idk why it didn't work as expected or why it works now, but it works, so this thread is closed.