Navigation and Pathfinding

Navigation and Pathfinding

术语:

  1)NavMesh 

  2)NavMesh Agent

  3)Off-Mesh Link

  4)NavMesh Obstacle

   

   A common algorithm to find the path is A* (pronounced “A star”), which is what Unity uses.

   Unity is using reciprocal velocity obstacles (RVO) to predict and prevent collisions.

  对于开放式场景,轨迹线不适用,NaviMesh此时就派上用场了。Unity的导航系统在已有的Mesh基础上生成一个新的FloorMesh,也叫NaviMesh。通过(menu: Window > Navigation)可以打开Navigation编辑器。

  

  

  Navigation Static:是否根据此网格生成Navimesh。

  OffMeshLink Generator:是否生成从此网格出发的Link。

  Navigation Layer:层。

  Bake页中包含更多内容。

  

  Radius: The Radius determines how close a navigating character can get to a wall and consequently the width of the narrowest gap between two walls that can it can squeeze through. 

  Height:efers to the height of the “ceiling” above the navmesh surface - an area may not be reachable simply because there is not enough headroom for the character

  Max Slope:parameter sets the threshold of steepness where a ramp becomes a wall

  Step Height: the maximum height of bump or step in the floor surface that is ignored by the character (any step greater than this height results in a disconnected walkable area rather than a continuation of the same area).

Off-mesh link

1、Manually create Off-Mesh Link.

  

  添加Off-mesh Link的步骤:

    1. First create two cylinders: Game Object > 3D Object > cylinder.
    2. You can scale the cylinders to (0.1, 0.5, 0.1) to make it easier to work with them.
    3. Move the first cylinder at the edge of the top platform, close to the NavMesh
       surface.
    4. Place the second cylinder on the ground, close to the NavMesh, at the location where the link should land.
    5. Select the cylinder on the left and add an Off-Mesh Link component to it. Choose Add Component from the inspector and choose Navigation > Off Mesh Link.
    6. Assign the leftmost cylinder in the Start field and rightmost cylinder in the End field.

参考:https://docs.unity3d.com/Manual/nav-CreateOffMeshLink.html

2、Building Off-Mesh Link Automatically.

  

  

  1、Drop-Down link generation is controlled by the Drop Height parameter. The parameter controls what is the highest drop that will be connected, setting the value to 0 will disable the generation.  

  2、Jump-Across link generation is controlled by the Jump Distance parameter. The parameter controls what is the furthest distance that will be connected. Setting the value to 0 will disable the generation.

参考:https://docs.unity3d.com/Manual/nav-BuildingOffMeshLinksAutomatically.html

Enabling a Character to Navigate

  

  

更多资料参考:~/Unity/Editor/Data/Documentation/html/en/Manual/Navigation.html

  

原文地址:https://www.cnblogs.com/tekkaman/p/4179408.html