wiki.sine.space | sinespace

Navigation bake

From wiki.sine.space
Revision as of 09:02, 16 January 2019 by Eric MA (Talk | contribs) (Created page with "The NavMesh function in Unity can help you define your region where is walkable and where is not, so if you have an auto-walk function for player or NPC, it can automatically...")

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

The NavMesh function in Unity can help you define your region where is walkable and where is not, so if you have an auto-walk function for player or NPC, it can automatically calculate the routes.

If you are interested in how to fully use the NavMesh function, please check [official tutorial of Unity].

Here, we will only introduce some basic method.

As an example, I created a region with some simple objects as obstacles.

Global.jpg


Create a NavMesh Map

First, Click the menu Window -> Navigation to call out the Navigation window(In Unity 2018, it's in Window -> AI -> Navigation). There are four tabs in Navigation Window: Agents, Areas, Bake and Objects.

The Agents tab is a place to record profiles for different parameters, when you attach Nav Mesh Agent component to a character, you can choose the agent profile you set in the agents tab.

Agents.jpg

The Areas tab is for define the layers of navigation. There is already 3 built-in layer: Walkable, Not Walkable and Jump. You can always add new layer if you need. The Cost defines whether the layer is hard to walk or not -- more cost, much harder. Normally, the Auto-walk will always choose a path with lower cost.

Areas.jpg

The Object tab is to set the navigation parameter for the objects in the scene. The 3 filters, All, Mesh Renderers, Terrains can help you to find the objects, and if we need to set an object walkable or not, pick the checkbox Navigation Static, then choose its layer. If you want set it jumpable, for example: jump across a gap between two platform, of jump down from somewhere high, you should also pick the Generate OffMeshLinks checkbox then choose the Jump layer for Navigation Area.

Object.jpg

The Bake tab includes all detail settings here. The Agent Radius defines the width of character and how narrow the path it could pass. Agent Height stands for the height of character, so if there is a height limitation area, the character shall not pass. Max Slope defines the maximum angle the character can move on, and objects lower than the step height will not be considered as an obstacle. Drop Height is the maximum height which the character can jump off, and jump distance is a horizontal distance which the character can jump across.

Bake.jpg

When all the settings are done, you can click the Bake button to generate the NavMesh Map. When it's complete, the Scene window will display the Navmesh map.

NavMesh.jpg

The NavMesh jumpable with off-Mesh links will have an arrow and circle like this:

Jumpable.jpg


Create a NPC moves in control of NavMesh