- Home /
How to bake nav mesh dynamically
I have a random level generator that builds levels out of preset pieces. I'd like to use Unity's built in Nav Mesh. Can I dynamically bake the mesh at run time?
Answer by WalterEspinar · Mar 04, 2017 at 02:20 PM
now its possible https://github.com/Unity-Technologies/NavMeshComponents
This should now be the accepted answer. official tutorial is here: https://unity3d.com/learn/tutorials/topics/navigation/setting-navmeshagent-destination But better and mnore succinct is Brackey's https://www.youtube.com/watch?v=FkLJ45Pt-mY
Answer by asafsitner · May 04, 2012 at 07:11 AM
UPDATE 2018: NOW YES, IT CAN, YOU NEED TO DOWNLOAD SOME STUFF
No, Unity cannot create a NavMesh
at runtime, or modify an existing one at runtime. A NavMesh
needs to be baked in the editor.
You might want to look into grid-based or map-based (which can technically be considered grid-based) navigation and pathfinding algorithms such as the ever-popular (and not without reasons) A*.
EDIT: However, it is now possible (since Unity 4.3) to dynamically cut holes in the navmesh with the `NavMeshObstacle` component's `carving` property.
If someone comes here looking to load in a Nav$$anonymous$$esh from a prefab or scene. This thread will help you. http://forum.unity3d.com/threads/122545-Problem-with-Nav$$anonymous$$esh-and-Asynchronous-load
for disappointment, hope they will include that in future release
I have used Aron Granberg's Astar Pathfinding Project extensively in the past. Great assets, the basic version is free and it allow for full runtime graph generation.
Answer by impdesign · Feb 12, 2016 at 01:46 PM
Though you cannot bake the nav mesh dynamically, the objects you are probably trying to place in the scene after runtime can have a component called "Nav Mesh Obstacle" and make sure that you have "Cave Only Stationary" set to true. If you place in one of these objects in the scene after rune time, it will actually "carve" out part of the nav mesh so your character cannot move there.
Your answer
Follow this Question
Related Questions
Dynamic location of 3 player 0 Answers
Gaps in the Nav mesh 0 Answers
Dynamic lighting, no baking, best result? 0 Answers
Dynamically building multi-floor buildings with navmesh 1 Answer