Search Unity

Navmesh generation for procedural tile-based setting

Discussion in 'Navigation' started by DocEntropy, Mar 4, 2015.

  1. DocEntropy

    DocEntropy

    Joined:
    Jan 6, 2015
    Posts:
    3
    Hi,

    I want to instantiate my setting at runtime, with random generated prefab tiles in a grid pattern, but I seem to be stuck at navmesh generation. What's the best way to do this?

    I want to use Unity's native navmesh manager, but how?

    The way I see it, I have two options:
    1) I bake the navmesh in the prefab tiles, but I have no idea how to / if I can save my navmesh in a prefab
    or
    2) I regenerate the navmesh at runtime, but how should I go about it?

    Help would be much appreciated
     
  2. rev087

    rev087

    Joined:
    Oct 3, 2013
    Posts:
    11
    As far as I know, there is no way to modify the NavMesh at runtime, so basically you can't use the built-in navigation if you're doing procedural level generation =(
     
  3. DocEntropy

    DocEntropy

    Joined:
    Jan 6, 2015
    Posts:
    3
    Thanks :( Guess I'll have to try a different approach.
     
  4. chanfort

    chanfort

    Joined:
    Dec 15, 2013
    Posts:
    641
    I am not sure about this, but there might be possible to bake navmeshes on individual tiles through editor and link these terrain tiles somehow. So on runtime it would be using only baked navigation. If your terrain is very large, there might be possible to load/unload distant tiles to keep memory not overcrowded. So I guess NavMesh and terrain info should be written somewhere in the disk while baking it and on runtime you can try to write some kind of loading/unloading interface.

    P.S. I never tried this, so it's just a bit wild thoughts :)
     
  5. Breyer

    Breyer

    Joined:
    Nov 10, 2012
    Posts:
    412
    Some procedural games use prebaked seamless tiles. This is the simplest way in Unity to achieve good looking procedural world with built-in navmesh because u could prebake everything in editor
     
  6. Jakob_Unity

    Jakob_Unity

    Joined:
    Dec 25, 2011
    Posts:
    269
    Currently it's not possible to do options 1,2 using the built-in navmesh system. However - those two features are currently in development.

    Currently the options are:
    1. Bake everything into the scene.
    2. with Unity5 you can additively load scenes including navmeshes (but at fixed positions).
    3. Load scenes as normal with prebaked navmesh - while counter-move the character. e.g. when going to tile to the right - load the scene and reposition the character on the left side of the new tile.

    These options all have limitations.
     
  7. Ricane

    Ricane

    Joined:
    Oct 9, 2013
    Posts:
    3
    @Jakob_Unity: Can you give us an approximate ETA for option #1 and #2?
     
  8. SemaphoreStudios

    SemaphoreStudios

    Joined:
    Jan 14, 2010
    Posts:
    111
    @Jakob_Unity

    Any update on support for making nav meshes at runtime?
     
  9. MCJOHNS117

    MCJOHNS117

    Joined:
    Sep 1, 2012
    Posts:
    9
    I see it on the road map for 5.4 to be released in or around March 2016. Nice to see its coming, but disappointed its going to take so long.
     
  10. oswaldo-vix

    oswaldo-vix

    Joined:
    Aug 30, 2012
    Posts:
    6
    You can create a free navmesh and put obstacles (NavMeshObstacle) in your dynamic tiles.

    If you are using unity 5 has the option of using obstacles in box format (reducing the amount of obstacles)... this seems to have a high processing cost!
     
  11. Lahzar

    Lahzar

    Joined:
    May 6, 2013
    Posts:
    87
    If you want results now, you should use a stronger pathfinding system. I would suggest A* or any other grid based system. Definently NOT a NavMesh system if its genereted with tiles! I use the A* Project, which I would heavily recommend. You would only need the free version for this, aswell! If youre new to this kind of stuff, quill18creates made a tutorial covering pretty much this exact thing!
     
    PhilippG likes this.