Search Unity

  1. Unity 2019.2 is now released.
    Dismiss Notice

Open World Navigation... is it impossible?

Discussion in 'Navigation' started by joshcamas, May 6, 2018.

  1. neoshaman

    neoshaman

    Joined:
    Feb 11, 2011
    Posts:
    4,566
    that's why you have the (temporary) big navmesh baked under them ... lol
    1. use the big navmesh for navigation
    2. sample the cell navmesh (not the big navmesh) to detect crossing
    3. if sample is same, do nothing, store sample as old sample
    4. if sample is different, new cell detected, create a link between current sample and old sample
    5. ...
    6. profit!
     
  2. joshcamas

    joshcamas

    Joined:
    Jun 16, 2017
    Posts:
    863
    Why not just use the big navmesh then, since a big navmesh doesn't slow things down.

    My issue is I don't want to have to build the entire navmesh of the entire world every time I change something.
     
  3. neoshaman

    neoshaman

    Joined:
    Feb 11, 2011
    Posts:
    4,566
    It should be automated, and you wouldn't have to build the entire mesh, just a portion around the cells (or group of cells) to update (it's a neighbor check after all). Anyway, your mind is set up already.
     
  4. joshcamas

    joshcamas

    Joined:
    Jun 16, 2017
    Posts:
    863
    I'm sadly still confused. you're saying I don't have to build the entire mesh, but then you say I need a big mesh as well as small meshes... I don't get it :'(

    But yea I think Ima go with the direction of either tile replacement (which is sorta supported already in A* pathfinding project) or mesh splitting (doesn't seem to be supported in base unity, possibly could get it working for A*)

    This would allow for simply updating whatever cells you want, without the need of an extra large navmesh nor links
     
    Last edited: May 16, 2018
  5. snacktime

    snacktime

    Joined:
    Apr 15, 2013
    Posts:
    2,428
    Rebuilding a navmesh doesn't rebuild the entire thing, it detects which tiles have changes and rebuilds those.
     
    joshcamas likes this.
  6. neoshaman

    neoshaman

    Joined:
    Feb 11, 2011
    Posts:
    4,566
    I was trying to provide an automation in edit time, basically you create a script that would detect and create stuff for you.
    The big navmesh would a temporary data use to give context to smaller navmesh that will be kept, and the context is used to find and build navmeshlink before being discarded.

    So in term of steps
    1 - create navmesh for all cells
    2 - load a single cell from the list of cells
    3 - load the neighbor of that cells
    4 - bake a context navmesh on all the cell at the same time
    5 - run a script that move a navmesh agent from cells to cells
    6 - everytime the agent sample two navmesh in delta time, check if there is navmesh link already, if no, create a navmesh link
    7 - once all link are created, discard the context
    8 - goto 2 until there is no cells left in the list

    Or you can do it by hand

    But why not use the big mesh? well it depend on how you manage your memory, the impact it has, how do you deal with event horizon, the cost of updating change, etc ... it's a cost benefit things. If you are constantly changing things, then only one cells (and the neighbor) need to be rebaked/automated, assuming big navmesh is costly to bake, but maybe the biggest cost is to have all the cells at the same time in order to bake.

    Let's say that's one more option in case you have problem.

    I was thinking that the big mesh could be a problem if a cell wasn't uploaded, and an AI wander off the void of that cells, but if you unload object based on distance, and a big navmesh cost is minimal, why not? Object would never meet an empty cells in theory. In practice, if you have streaming, you can have cells poping up when player move too fast and then have ai falls down the world map. Happen in AAA games.
     
    joshcamas and GameDevCouple_I like this.
  7. joshcamas

    joshcamas

    Joined:
    Jun 16, 2017
    Posts:
    863
    I understand now. I'm thinking for now I'm just going to have a big navmesh, like you said... however I do plan in the future to switch to arongranberg's A* pathfinding project, and since he has a feature implemented where you can save/load tiles, I'll be doing that.

    :) Thank you all very much for your help!!! And thank you neoshaman for your patience xD
     
    neoshaman likes this.
  8. snacktime

    snacktime

    Joined:
    Apr 15, 2013
    Posts:
    2,428
    Make sure to test the A* project thoroughly end to end before starting to replace the unity stuff. The A* navmesh implementation is just not the same quality and it shows in several areas.
     
    FlightOfOne, RogDolos and joshcamas like this.
  9. joshcamas

    joshcamas

    Joined:
    Jun 16, 2017
    Posts:
    863
    Oh, really? I figured it would be better, since it's... well, not closed source, and costed me $70 :^^^) I'll be sure to make sure, thank you very much for the warning!
     
  10. snacktime

    snacktime

    Joined:
    Apr 15, 2013
    Posts:
    2,428
    joshcamas likes this.
  11. joshcamas

    joshcamas

    Joined:
    Jun 16, 2017
    Posts:
    863
    whaaaaaaaaaat I HAD NO IDEA
     
  12. purnamasari

    purnamasari

    Joined:
    Mar 8, 2018
    Posts:
    17
    Hello, have you managed this navigation things already? I'm planning to do similar things, well, generating navmesh at the runtime will be such a pain but load huge navmesh isn't a wise choice at all. I would love to hear how you can achieve them, your method, tricks, and any tips surely can be useful for me.

    Been stressed out because this things :(
     
  13. joshcamas

    joshcamas

    Joined:
    Jun 16, 2017
    Posts:
    863
    The only answer I can give is to buy the A* Pathfinding Project. This allows you to swap out tiles of the navmesh, and this should solve your issue. (aka save tiles / groups of tiles and then add / remove them to navmesh during runtime).

    Sadly it looks like Unity doesn't seem to be interested in having accessible navmesh data (same goes for lighting data), so we're stuck with using alternative products.
     
  14. appmob82

    appmob82

    Joined:
    Aug 3, 2014
    Posts:
    1
    i'm working on open-world game but generated at run time.. i come up with a solution.. you may try it..
    make small blocks cover the walkable area with box collider and navmeshsurface components "use from prefab" and make two layers names "layer1 - layer2" and assign it to the blocks and set navmeshsurface collect Object property to "Volume" and set the size as you wish and set include layers "layer1" .. and generate navmesh with volume from any of the blocks..
    while player moving after a certain distance get the block under the player by recasting and switch layer of all block to the "layer2" and generate the nave mesh..
    this will make the baking smooth..
    and of course keep reference to the old block with old navmesh to get ride of it after the net mesh generated..
     
  15. joshcamas

    joshcamas

    Joined:
    Jun 16, 2017
    Posts:
    863
    Interesting concept, that is certainly better than always regenerating the navmesh! Sadly I'm personally looking for a solution that doesn't involve generating the navmesh at runtime at all, but regardless that's a pretty cool solution!