【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:
添加Off-mesh Link的步骤:
- First create two cylinders: Game Object > 3D Object > cylinder.
- You can scale the cylinders to (0.1, 0.5, 0.1) to make it easier to work with them.
- Move the first cylinder at the edge of the top platform, close to the NavMesh
surface. - Place the second cylinder on the ground, close to the NavMesh, at the location where the link should land.
- 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.
- Assign the leftmost cylinder in the Start field and rightmost cylinder in the End field.
参考:https://docs.unity3d.com/Manual/nav-BuildingOffMeshLinksAutomatically.html
Enabling a Character to Navigate