Development environment: WIN10, Unity5.3.4, C #, VS2015
Date Created: 2016-05-09 I. INTRODUCTION
The OFF mesh link component is used to manually specify alignments to generate detached mesh connections. For example, a scenario in which a moving object climbs up and down a ladder to another grid is achieved by creating a detached grid connection.
1. Basic operation
After you select a navigation mesh geometry in the scene, in the viewer view, right-click the drop-down box on the right side of static to mark the off mesh link Generation as the detached grid links, as shown in:
Static geometry, marked in this manner, is automatically checked during the navigation mesh baking process and links to other navigation grid (Navmesh) geometry are created accordingly. In this way, the automatic generation of each game object (Gameobject) can be controlled separately.
In addition, the automatic generation of detached mesh links during the baking process also depends on the jumping distance (jump distance) and drop height properties in the Navigation Baking (Bake tab) settings:
You can also switch to the "Object" tab and assign the Navmeshlayer to automatically generate a detached mesh link as a built-in hop (jump):
This allows global control to automatically generate detached mesh links (see Navmesh layer).
2, areas
The main task of the navigation system is to find the best path between two points in the navigation space. The simplest case is that the best path is the shortest path. However, in many complex environments, some regions may be more difficult to traverse than others (for example, crossing a river is more time-consuming and laborious than passing the bridge). To emulate this, Unity introduces the concept of cost and defines the least cost path as the best path (optimal path).
To manage the cost of each grid, unity specifies that each geometry labeled as a static navigation mesh (Navmesh static) belongs to the navigation grid layer (Navmesh layer). Go to the Areas tab to observe these layers, or you can customize the layer:
During pathfinding, Unity does not compare the length of a potential path fragment, but rather evaluates the cost of each fragment's consumption, and the path with the lowest cost total is the best path.
When all costs are set to 1 o'clock, the best path is the same as the shortest path. Ii. examples
This example shows how to manually specify a route to detach a grid connection.
1. Set the detached component link
In the Ch1201_navmesh_sample project, create a new scene named Demo2 that creates 2 cubes in the scene, sets it to static separately, and then clicks the Bake button in the Navigation window to bake the navigation grid as shown in:
2. Add 2 cubes, set it to red, and then replace the red cube below with the name start point, and replace the Red cube on the top with an end point, as shown in:
With start point selected, select "Component", "Navigation", "Off Mesh Link" in the menu, as shown in:
This adds the off Mesh link component to the start point object, as shown in:
2. Baking
(1) as described in the previous section, add a green target cube and then add a capsule body as the traveling object.
(2) Switch to the "Navigation" window and observe the parameter settings:
Click the Bake button to complete the baking process. As shown in the following:
3. Observing the path of pathfinding
Click the Play button to observe the animation process of the capsule body (player) auto-pathfinding. At this point, the capsule body (player) is close to the start point, then "rub" the ground up to the end point and finally to the target (Greencube).
In this example, the capsule body to start point, the reason for the "rub" on the ground up, because the system is the default way. If you want to enrich the ascent process, such as playing a ladder or a flight, you can control it by script. Specific usage will also be introduced in future development examples.
"Unity" 12.3 Off Mesh Link Component