查看: 1956|回复: 0
打印 上一主题 下一主题

[Unity 组件参考手册]组件:管理器设置之导航网格层(仅专业版)

[复制链接]
.    

3797

主题

11

听众

5万

积分

首席设计师

Rank: 8Rank: 8

纳金币
32328
精华
41

活跃会员 优秀版主 荣誉管理 论坛元老

跳转到指定楼层
楼主
发表于 2013-1-31 22:29:38 |只看该作者 |倒序浏览
The primary task of the navigation system is finding the optimal path between two points in navigation-space. In the simplest case, the optimal path is the shortest path. However, in many complex environments, some areas are harder to move t*** than others (for example, crossing a river can be more costly than ***nning across a bridge). To model this, Unity utilizes the concept of cost and the optimal path is defined as the path with the lowest cost. To manage costs, Unity has the concept of Navmesh Layers. Each geometry marked up as Navmesh Static will belong to a Navmesh Layer.
寻路系统的首要任务是找到寻路空间中2点的最优路径。在最简单的情况下,最优路径即最短路径。然而,在许多复杂的环境中,某些区域很难穿越(例如,穿过一条河流比通过桥梁更加费事)。为了模拟这些情况,unity引入代价和最优路径概念,即最低代价路径。unity使用导航网格层(Navmesh Layers)来管理路径代价。标记为静态导航网格的所有几何体都属于导航网格层。
During pathfinding, instead of comparing lengths of potential path segments, the cost of each segment is evaluated. This is a done by scaling the length of each segment by the cost of the navmesh layer for that particular segment. Note that when all costs are set to 1, the optimal path is equivalent to the shortest path.
寻路过程将对可能的路径进行代价评估,而不是进行长度比较。处理方法是对路径长度根据导航网格层的代价进行缩放。请注意,所有代价都设置为1时,最优路径相当于最短路径。
To define custom layers per project
设置项目的自定义层
    Go to Edit->roject Settings->Navmesh Layers

    打开Edit->roject Settings->Navmesh Layers

    Go to one of the user layers, and set up name and cost

    到一个用户层,设置名称和代价值。

        The name is what will be used everywhere in the scene for identifying the navmesh layer

        名称用来在场景中标识导航网格层。

        The cost indicates how difficult it is to traverse the NavMesh layer. 1 is default, 2.0 is twice as difficult, 0.5 is half as difficult, etc.

        代价值表示在导航网格层上移动的难易程度。默认为1, 2表示2倍难度,0.5表示为默认难度的一半。

    There are 3 built-in layers 有3个内置的层。

        Default - specifies the cost for everything not otherwise specified

        默认-所有没有做特殊设置的物体的默认代价值。

        Not walkable - the cost is ignored

        不可穿越-代价值忽略

        Jump - the cost of automatically generated off-mesh links

        跳跃-自动生成的分离网格的代价
To apply custom layers to specific geometry
将自定义的层应用到指定几何体的步骤
    Select the geometry in the editor

    编辑器中选择几何体

    Pull up the Navigation Mesh window (Window->Navigation Mesh)

    调出导航网格窗口(Window->Navigation Mesh)

    Go to the Object tab, and select the desired Navigation layer for that object

    到Object标签,为物体选择你要设置的寻路层。

    If you have Show NavMesh enabled in the Navmesh Display window, the different layers should show up in different colors in the editor.

    如果你在导航网格窗口启用了Show NavMesh选项,在编辑器中,不同的导航网格层会显示为不同的颜色。
To tell an agent what layers he can or cannot traverse
如果你想让代理组件知道哪个层不能穿越
    Go to the NavMeshAgent component of the agent's geometry

    打开几何体的导航网格代理NavMesh Agent组件

    Modify NavMesh Walkable property

    更改NavMesh Walkable属性

    Don't forget to set the agent's destination property from a script

    不要忘记在脚本中设置代理的终点属性
Note: Setting the cost value below 1 is not recommended, as the underlying pathfinding method does not guarantee an optimal path in this case
注意:不建议把代价值设置为小于1的数值,因为这样的话寻路算法不能保证得到最优路径。
One good use case for using Navmesh Layers is:
导航网格层的一个应用示例:
    You have a road that pedestrians (NavmeshAgents) need to cross.

    行人(导航网格代理)需要穿越一条道路

    The pedestrian walkway in the middle is the preferred place for them to go

    行人最好在人行横道上走。

    Set up a navmesh layer with high cost for most of the road, and a navmesh layer with a low cost for the pedestrian walkway.

    我们可以把路面的大部分设置为高代价的导航网格层,把人行道设置为低代价的导航网格层

    This will cause agents to prefer paths that go t*** the pedestrian walkway.

    这样就可以让代理的寻路结果为人行道
Another relevant topic for advanced pathfinding is Off-mesh links
关于高级寻路的另一个相关主题是分离网格链接Off-mesh links。
【来源:互联网】

更多精彩教程,尽在web3D纳金网http://www.narkii.com/college/
分享到: QQ好友和群QQ好友和群 腾讯微博腾讯微博 腾讯朋友腾讯朋友 微信微信
转播转播0 分享淘帖0 收藏收藏0 支持支持0 反对反对0
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

手机版|纳金网 ( 闽ICP备2021016425号-2/3

GMT+8, 2024-11-14 13:28 , Processed in 0.091586 second(s), 33 queries .

Powered by Discuz!-创意设计 X2.5

© 2008-2019 Narkii Inc.

回顶部