The process of creating a NavMesh from the level geometry is called NavMesh Baking. The process collects the Render Meshes and Terrains of all Game Objects which are marked as Navigation Static, and then processes them to create a navigation mesh that approximates the walkable surfaces of the level.
In Unity, NavMesh generation is handled from the Navigation window (menu: Window > AI > Navigation (Obsolete)).
为场景构建导航网格可以通过 4 个快速步骤完成:
每当 Navigation 窗口打开且可见时,生成的导航网格便会在场景中显示为底层关卡几何体上的蓝色覆盖层。
您可能已经在上面的图片中注意到,生成的导航网格中的可行走区域显示为缩小状态。导航网格表示代理中心可进行移动的区域。从概念上讲,无论将代理视为缩小的导航网格上的点还是全尺寸的导航网格上的圆都无关紧要,因为这两者是等效的。但是,解释为点有助于提高运行时效率,并可让设计人员立即看到代理是否可以挤过间隙而不用担心代理半径问题。
Another thing to keep in mind is that the NavMesh is an approximation of the walkable surface. This can be seen for example in the stairs which are represented as a flat surface, while the source surface has steps. This is done in order to keep the NavMesh data size small. The side effect of the approximation is that sometimes you will need to have a little extra space in your level geometry to allow the agent to pass through any tight spots.
烘焙完成后,您将在一个与导航网格所属场景同名的文件夹中找到导航网格资源文件。例如,如果在 Assets 文件夹中有一个名为 First Level 的场景,则导航网格将位于 Assets > First Level > NavMesh.asset。
Did you find this page useful? Please give it a rating:
Thanks for rating this page!
What kind of problem would you like to report?
Thanks for letting us know! This page has been marked for review based on your feedback.
If you have time, you can provide more information to help us fix the problem faster.
Provide more information
You've told us this page needs code samples. If you'd like to help us further, you could provide a code sample, or tell us about what kind of code sample you'd like to see:
You've told us there are code samples on this page which don't work. If you know how to fix it, or have something better we could use instead, please let us know:
You've told us there is information missing from this page. Please tell us more about what's missing:
You've told us there is incorrect information on this page. If you know what we should change to make it correct, please tell us:
You've told us this page has unclear or confusing information. Please tell us more about what you found unclear or confusing, or let us know how we could make it clearer:
You've told us there is a spelling or grammar error on this page. Please tell us what's wrong:
You've told us this page has a problem. Please tell us more about what's wrong:
Thank you for helping to make the Unity documentation better!
Your feedback has been submitted as a ticket for our documentation team to review.
We are not able to reply to every ticket submitted.