Search Unity

Pathfinding for Large Worlds

Discussion in 'Navigation' started by unity_1SeL-HQ69UMA9g, Jun 14, 2018.

  1. unity_1SeL-HQ69UMA9g

    unity_1SeL-HQ69UMA9g

    Joined:
    Oct 7, 2017
    Posts:
    8
    Worlds are procedural generated.

    Hello, i am looking for pathfinding, that will be used on large worlds (2000x2000).
    What should i use? I was in almost every thread, on every page and didn't find out :/
     
  2. dgoyette

    dgoyette

    Joined:
    Jul 1, 2016
    Posts:
    4,196
    Well, if it's a procedurally generated world probably your only option is baking the navmesh at runtime. There's a tutorial on that, using the NavMeshComponents system:

    https://unity3d.com/learn/tutorials/topics/navigation/baking-navmesh-runtime

    That said, I'm not sure whether the baking can be constrained to ignore certain chunks of your world. One approach would be to disable the colliders that are far from the player, and rebake as necessary as the player gets closer to that region. For example, assuming your world is broken into square regions, maybe you disable colliders in all but the 9 squares adjacent to the player. When the player moves to a new region, you'd enable/disable colliders in the different areas, and rebake the mesh.

    That's probably only valid if you can't meaningfully interact with parts of the world that are 2000 units away from the player... But this is just an optimization, and maybe it'll work fine even if you keep everything enabled all the time.
     
  3. unity_1SeL-HQ69UMA9g

    unity_1SeL-HQ69UMA9g

    Joined:
    Oct 7, 2017
    Posts:
    8
    No NavMesh is really bad and old. I bought A*. Its a lot better
     
  4. grant_from_mercuna

    grant_from_mercuna

    Joined:
    Jun 26, 2018
    Posts:
    6
    I agree, some of the native solutions have limited functionality. For more nuanced uses, you need to look for different solutions