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.
So far I've thought of two solutions. I'm hoping someone thinks of something better :-)
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. :-)
Answer by Fredex8 · Mar 02, 2016 at 06:47 PM
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:
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.
Yeah. The solution you talk about is what I've been using in the Development $$anonymous$$ode.
Are you 100% sure that I'll be able to call BuildNav$$anonymous$$esh at runtime in version 5.5? In that case I can live with building the game in Development mode until 5.5 is released. Not going to get close to a finished state by June anyway :P
Can never be 100% sure of course as there could be delays in the development that push it back to a later version. Also it probably won't be 'BuildNav$$anonymous$$esh' but something else ins$$anonymous$$d.
The description for Bake API sounds like it is talking about building a navmesh at runtime though so personally I'm going to wait until June before I start worrying about building custom navigation options to get around the lack of it currently.
Sounds great! Thanks for the information! :-D This allows me to continue working on, the main part is that any builds I have to make before the Baking API becomes available have to be Debug mode.
Thanks for the help!