Version: 2022.3
Creating an OffMesh Link
构建高度网格以准确放置角色

Building OffMesh Links Automatically

Some use cases for OffMesh Links can be detected automatically. The two most common ones are: Drop-Down and Jump-Across.

  • 掉下链接的作用是从平台上掉下。
  • 跳过链接的作用是跳过缝隙。

In order to find the jump locations automatically, the build process walks along the edges of the NavMesh and checks if the landing location of the jump is on NavMesh. If the jump trajectory is unobstructed an OffMesh link is created.

Let’s set up automatic OffMesh Link generation. If you’re not familiar with NavMesh baking, take a look at Building a NavMesh.

First, the objects in the Scene where the jump can start from needs to be marked. This is done by checking Generate OffMesh Links in the Navigation (Obsolete) window under Objects tab.

第二步是设置掉下和跳过轨迹:

  • 掉下链接的生成由 Drop Height 参数控制。该参数可控制将要连接的最高掉落高度,将值设置为 0 将禁用生成。
    • 定义掉下链接的轨迹时应使水平行程 (A) 为:_2*agentRadius + 4*voxelSize。即,掉落将刚好落在平台的边缘之外。此外,垂直行程 (B) 需要大于烘焙设置的 Step Height_(否则只会走下平台)并小于 Drop Height。应按体素大小进行调整,确保在体素化期间的任何舍入误差都不会阻止生成链接。应将 Drop Height 的值设置得比在关卡中测量的值略大,使链接正确连接。
  • 跳过链接的生成由 Jump Distance 参数控制。该参数可控制将要连接的最远距离。将值设置为 0 将禁用生成。
    • 定义跳过链接的轨迹时应使水平行程 (C) 大于 2*agentRadius 且小于 Jump Distance。此外,着陆位置 (D) 不得超过距离起始位置关卡的 voxelSize。

Now that objects are marked, and settings adjusted, it’s time to press Bake and you have will have automatically generated OffMesh links! When ever you change the scene and bake, the old links will be discarded and new links will be created based on the new scene.

故障排除

Things to keep in mind if OffMesh links are not generated at locations where you expect them to be:

  • Drop Height 应当比在关卡中测量的实际距离略大一点。这样可确保在导航网格烘焙过程中发生的小偏差不会阻止链接的连接。
  • Jump Distance 应当比在关卡中测量的实际距离略远一点。Jump Distance 是从导航网格上的一个位置到导航网格上的另一个位置之间的测量值,这意味着应加上 _2*agentRadius_(加一点)才能确保跨过缝隙。

Additional resources

Creating an OffMesh Link
构建高度网格以准确放置角色