在Unity中,NavMesh 的生成操作需要Navigation窗口(在Window> Navigation)
在你的場景中構建NavMesh只需要4個步驟:
當你的Navigation窗口打開并且可見時,烘焙的NavMesh結果在場景中會以藍色的覆蓋層在物體的幾何體表面顯示。
When%20baking%20is%20complete,%20you%20will%20find%20a%20NavMesh%20asset%20file%20inside%20a%20folder%20with%20the%20same%20name%20as%20the%20scene%20the%20NavMesh%20belongs%20to.%20For%20example,%20if%20you%20have%20a%20scene%20called First%20Level in%20the%20Assets%20folder,%20the%20NavMesh%20will%20be%20at Assets%20>%20First%20Level%20>%20NavMesh.asset.當烘焙結束后,你可以找到一個名字和你的場景名一樣的文件夾,里面有一個NavMesh的資源文件,是屬于這個場景的NavMesh。
直接選擇物體在Inspector面板頂部的Static 菜單,你可以直接選擇Navigation Static,而不用再打開Navigation 窗口。
Min Region Area 允許你剔除掉小的非連接NavMesh區域,當NavMesh區域小于指定值時將被剔除。
請注意:有些區域可能無法被移除,盡管有Min Region Area 的設置,原因是NavMesh的構建是一個個的網格并行構建。當一個區域橫跨兩個網格將不會被移除,因為區域修剪過程中無法獲取到周圍的網格。
Manual voxel size :允許你改變烘焙操作過程中的精確性。
Navigation在構建尋路網格過程中,第一遍會把場景光柵化為體素,然后提取可行走區域,最后可行走區域會烘焙成網格。因此體素尺寸Voxel Size的決定了尋路網格烘焙的精準性。
提示:默認的體素設置最好的權衡了準確性和烘焙速度。在烘焙場景尋路的過程中,體素的增加會造成4x倍的內存消耗和4x倍的時間消耗。因此通常,你不需要自己去設置Voxel Size。
系統烘焙尋路是也會減小voxel size。如果你的agent尺寸保持不變,可能不需要增加NavMesh的構建分辨率。
更簡單的方法如下所示:
設置你的半徑為真實agent半徑打開Manual Voxel Size,這會保持當前的voxel的大小并且凍結它。人為的將你的Agent Radius設置小,因為你已經勾選了Manual Voxel Size ,voxel size將不會改變。Height mesh : 允許你為角色提供更精準的位置。
While navigating, the NavMesh Agent is constrained on the surface of the NavMesh. Since the NavMesh is an apPRoximation of the walkable space, some features are evened out when the NavMesh is being built. For example, stairs may appear as a slope in the NavMesh. If your game requires accurate placement of the agent, you should enable Height Mesh building when you bake the NavMesh. The setting can be found under the Advanced settings in Navigation window. Note that building Height Mesh will take up memory and processing at runtime, and it will take a little longer to bake the NavMesh.
盡管普通的NavMesh 已經可以很好的運行,但是由于NavMesh只是一個近似的可行走的空間,只保持了一些均衡的特性,如果你的游戲agent需要更精準的行走位置,你可以啟用高度網格Height Mesh,新聞熱點
疑難解答