Tip:
Highlight text to annotate it
X
In the previous movie, we set up a line of communication between our game engine
and Kynapse, and then used Kynapse to make bots aware of dynamic bodies
in our game environment.
In this movie, we’ll use the included Kynapse Lab tool to build a map of the game environment
that our bot can use to navigate the terrain.
To determine where a bot can or can’t go,
Kynapse uses a process called Path Data Generation, or PDG for short.
If you have a .obj file of your game’s terrain,
you can generate this path data using the Kynapse Lab tool,
found in the “tools” folder in your Kynapse install directory.
You will need to build the Kynapse Lab project first before you can use it.
To launch Kynapse Lab you’ll need to license it by placing your license information
in the Kynapse root folder via a file called Kynapse.key.
You can now open the Kynapse Lab executable in the “bin” folder.
To import your .obj file, go to File > Import a graphic world.
If your mesh isn’t oriented properly,
you can adjust the Axes and One Meter values in File > Options window.
To navigate your terrain in Kynapse Lab,
hold Shift and drag the mouse to tumble…
…hold Shift and right-drag the mouse to zoom…
…and hold Ctrl + Shift and drag the mouse to pan.
Now you can use the Generate button to generate path data.
Kynapse Lab forms a PDG that consists of two main parts – a NavMesh and a Graph.
For now, let’s look at a monochrome version of our city to better visualize these elements.
Clicking the Display NavMesh button shows the NavMesh,
a set of triangles that represent areas of the 3D world that are navigable.
Any areas without these triangles are said to be “outside the NavMesh” and thus unnavigable.
Clicking the "Display Graph" button, followed by the rendering option, displays the graph in green.
This graph represents the basic paths a bot can take from point A to point B.
Since the graph is less elaborate than the NavMesh,
Kynapse can calculate paths much more quickly.
However, that doesn’t mean that bots are limited to walking along these edges.
The graph is used only to generate the high-level, initial path.
As a bot follows that initial path, Kynapse has various methods of smoothing its trajectory
so that it doesn’t perform unnecessarily wide turns or other unnatural looking movement.
Remember though, that our actual environment isn’t monochrome.
The triangles of the city are colored.
These colors represent terrain types.
Each bot may navigate terrain types differently, depending on the conditions of your game.
For example, when all's normal these bots stick to walking on sidewalks and crosswalks.
However, in a panic, we can quickly make them run on the roads as well.
When using Kynapse Lab to generate Path Data,
Terrain Types are automatically assigned based on the material of each triangle in the geometry.
You can re-assign terrain types with the Terrain Type Volume tool.
Click the "Add terrain type volume" button in the Generation tab.
Kynapse Lab creates a new terrain type volume in the tree.
Right-click the terrain type volume and select "Add vertices picking in viewport".
Now use "Pick Geometry" mode to choose the vertices of your volume by Ctrl + clicking.
Notice that as you add vertices to the volume they appear in the tree under the terrain type volume
Let’s also increase the max altitude of this volume for possible flying characters.
Now you can use the "Terrain Type" field to assign the volume a unique "Terrain Type Mask",
which will be applied to all triangles in the volume.
Finally, you can insert optional seed points using the Seed Point tool.
Seed points determine a bot’s “starting position” and,
combined with that bot’s Body Attributes (as seen in the previous movie),
it helps you refine your PDG.
For example, if we look at the city shown here,
notice that the NavMesh and graph cover the streets as well as the rooftops.
However, if our bot cannot jump high enough to reach those rooftops,
then there’s really no reason to generate that rooftop data.
If we click the "Add seed points" button and then Ctrl + Click a vertex at street level,
we can set a seed point there. Now if we regenerate the path data,
Kynapse will be able to calculate that there’s no way for the bot to reach the roofs,
and thus will ignore them when generating path data.
Kynapse Lab also features a wide variety of tools for testing your PDG.
These can be found in the Tools menu.
Although we won’t cover the specific tests here,
you can find more information on each of them in the Kynapse documentation.
While Kynapse Lab is a powerful tool for the PDG process,
you may want an even greater degree of customization
depending on the needs of your specific engine.
We’ll address these concerns in the next movie,
by showing you how to integrate the PDG process directly into your game.