Id need some help with Navmesh and Tiles

Hey guys!

I’m working on a tiled tycoon game.
During most of the development I’ve been using unitys NavMesh and I used the UnityEditor class to force it to build the navmesh once the tiles are placed in the world.
Great! That worked great. However, It’s starting to approach where I need to step out of development environment and make the game run on it’s own.

That’s where I encounter a problem tho.
I can easily get the Navmesh to bake on the Tile-prefab I have. However, when I instantiate it and create the world, the Navmesh doesn’t appear on any other tiles.
I’m not sure how to solve this issue.

Here’s a screenshot displaying the issue. P.S. Each tile is made out of a plane. D.S.
Screenshot

So far I’ve thought of two solutions. I’m hoping someone thinks of something better :slight_smile:

Solution 1 - Step away from Unity’s Navmesh and write my own one. Which is not really a good solution because It’ll take a very very long time.

Solution 2 - Create a pre-baked plane which matches the size of the map that’s generated. This solution will prevent me from making the map expandable though.

I’d really appreciate if someone could help me out with this issue. :slight_smile:

The navmesh should work fine for your game but not by applying it to individual tiles like that. It’s going to result in creating gaps between each tile which are not navigable.

Using a single plane as the navmesh is probably the best solution and there are ways you could make it able to expand still by creating the navmesh at runtime rather than in the editor.

I’ve yet to get around to trying this but I think that should do what is required here:

NavMeshBuilder.BuildNavMesh

No documentation on that there though so it may take some reading up on.

EDIT: It would appear this still cannot be called at runtime. I thought that had been changed in Unity 5. Apparently it is scheduled for 5.5 https://unity3d.com/unity/roadmap

Even without that there are hacky ways you could do it like having a much larger plain as the navmesh with navmesh obstacles blocking it around the edges and carving it down to size which are then removed to make it larger. Not a good solution but that would work too.