Search Unity

Problem with NavMesh and Asynchronous load

Discussion in 'Developer Preview Archive' started by Dabor, Feb 8, 2012.

  1. Dabor

    Dabor

    Joined:
    Feb 8, 2012
    Posts:
    2
    Hi,

    I'm having trouble with NavMesh. When loading a level with LoadLevelAdditiveAsync the navmesh is not loaded, so all the NavMeshAgents show the error "Failed to create agent because there is no valid NavMesh". I need to use asynchronous load, so I need to know if it's a bug or there is a different way to load the navmesh asynchronously.

    Thank you.
     
  2. Dreamora

    Dreamora

    Joined:
    Apr 5, 2008
    Posts:
    26,601
    Asyncronous load is no problem but you can not load additive. (same limitation as with Beast and Umbra)
    So you are free to use LoadLevelAsync, no problem, but you can't combine scenes together, as you can have a single navmesh only per scene and thats the one thats in the 'loadlevel' scene. The other scenes can only contain 'visual additions' or dynamic objects but no navmesh / static data
     
  3. Dabor

    Dabor

    Joined:
    Feb 8, 2012
    Posts:
    2
    It worked fine!

    Thanks a lot!
     
  4. Ulisse

    Ulisse

    Joined:
    Jan 8, 2012
    Posts:
    6
    I have a similar problem
    I start my application from an almost empty scene which just contains a dummy GameObject with a manager attached to it.
    To load the other scenes (some containing a navmesh, others no) I use LoadLevelAdditiveAsync but I get an error because Unity cannot find the navmesh.

    Thank you

    P.S. ....Obviously moving from a scene to another I just keep my dummy while destroy everything else
     
    Last edited: Feb 20, 2012
  5. fox

    fox

    Joined:
    Jan 14, 2009
    Posts:
    118
    Does anyone know if this limitation has been reported as a bug? It should most definitely be treated as one, as it's a limit making the additive load useless in many cases.
     
  6. OneThree

    OneThree

    Joined:
    Oct 28, 2011
    Posts:
    181
    Has there been any update on this? I agree with Fox that not being able to load navmeshes when additively loading a level is a huge limitation.
     
  7. OneThree

    OneThree

    Joined:
    Oct 28, 2011
    Posts:
    181
    Actually, I just found a way around this. It's a little ugly, but it does exactly what I need. In my case, I want to have one lightweight level for gameplay objects and data, then I want to load one of three different art-only levels. The art-only levels each have their own navmesh data, which I want to load in with them.

    Additive loading doesn't allow you to do this, but my workaround is to set Object.DontDestroyOnLoad on all of the objects from my gameplay level that I want to keep around. This seems like it would be a hassle, but fortunately I found that if you set DontDestroyOnLoad on an object it also applies to all of its children. So I've just taken the entire hierarchy of my gameplay scene and put everything under a dummy parent called Persistent. Then I just have to set DontDestroyOnLoad to True on Persistent and all of the other objects are protected.

    When doing this, make sure that the dummy parent is at 0,0,0 and has a transform of 1,1,1 with no rotation, so that you don't have to start worrying about local versus world coordinates.

    After doing that you can do a non-additive load, which will bring in the navmesh from the newly-loaded level while still preserving the gameplay data under Persistent.

    It's technically not an additive load since the original level is technically unloaded, but since the objects under Persistent aren't destroyed it achieves the same purpose as an additive load while also letting you load navmesh data. It takes a little bit of hierarchy setup, but after that all is well.

    Hope this helps!
     
    Good_Rabbi, boromir6 and boddole like this.