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?
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.
now its possible
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.