This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionNext revisionBoth sides next revision | ||
gamedev:navigation [2012/12/01 17:41] – dragonlord | gamedev:navigation [2019/05/08 17:40] – dragonlord | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | {{tag> | ||
<WRAP youarehere> | <WRAP youarehere> | ||
[[: | [[: | ||
Line 4: | Line 5: | ||
====== Navigation System ====== | ====== Navigation System ====== | ||
- | <WRAP box 250px right :en>{{ :gamedev:images: | + | <WRAP box 250px right :en>{{ : |
The navigation system provides the game with the necessary tools to choose a path through the game world. Often this is simply called **Path Finding**. Path finding by itself though is just one part of a navigation system albeit an important one. In the Drag[en]gine the navigation problem is represented using 3 main classes. These are the **Navigation Space**, **Navigator** and **Navigation Blocker** classes. In the rest of this text **Navigation System** is used as the grouping name for a set of spaces, navigators and blockers working together. | The navigation system provides the game with the necessary tools to choose a path through the game world. Often this is simply called **Path Finding**. Path finding by itself though is just one part of a navigation system albeit an important one. In the Drag[en]gine the navigation problem is represented using 3 main classes. These are the **Navigation Space**, **Navigator** and **Navigation Blocker** classes. In the rest of this text **Navigation System** is used as the grouping name for a set of spaces, navigators and blockers working together. | ||
Line 27: | Line 28: | ||
===== Navigation Grid ===== | ===== Navigation Grid ===== | ||
- | <WRAP box 250px right :en>{{ :gamedev:images: | + | <WRAP box 250px right :en> |
+ | {{ : | ||
+ | <WRAP centeralign> | ||
+ | </ | ||
Navigation grids are useful for navigation problems where an exact and smooth path is not required. This is usually used for coarse grained navigation typically not directly linked to a visible world or checker board type navigation. In this navigation space vertices are the nodes and edges are the connections between nodes. | Navigation grids are useful for navigation problems where an exact and smooth path is not required. This is usually used for coarse grained navigation typically not directly linked to a visible world or checker board type navigation. In this navigation space vertices are the nodes and edges are the connections between nodes. | ||
Line 34: | Line 38: | ||
===== Navigation Mesh ===== | ===== Navigation Mesh ===== | ||
- | <WRAP box 250px right :en>{{ :gamedev:images: | + | <WRAP box 250px right :en> |
+ | {{ : | ||
+ | <WRAP centeralign> | ||
+ | </ | ||
Navigation meshes are useful for all kinds of navigation problems in detailed scene geometry where a smooth path around the world is desired. This is the typical space used for AI navigation of visible game actors. Most of the time you want to use this type of navigation space. In this navigation space faces are the nodes and edges the connections between them. In contrary to the navigation grid the connection is located at the edges of the face hence you do not travel along them but simply cross them. | Navigation meshes are useful for all kinds of navigation problems in detailed scene geometry where a smooth path around the world is desired. This is the typical space used for AI navigation of visible game actors. Most of the time you want to use this type of navigation space. In this navigation space faces are the nodes and edges the connections between them. In contrary to the navigation grid the connection is located at the edges of the face hence you do not travel along them but simply cross them. | ||
Line 47: | Line 54: | ||
===== Parameter Summary ===== | ===== Parameter Summary ===== | ||
<WRAP column 45%> | <WRAP column 45%> | ||
- | **Navigation Space** | + | <WRAP boxheader> |
+ | <WRAP boxcontent> | ||
^Name^Description^Value^ | ^Name^Description^Value^ | ||
|Layer|Layer this navigation space affects|Integer| | |Layer|Layer this navigation space affects|Integer| | ||
|Type|Space type|Grid, Mesh or Volume| | |Type|Space type|Grid, Mesh or Volume| | ||
+ | </ | ||
<WRAP boxheader> | <WRAP boxheader> | ||
Line 58: | Line 67: | ||
</ | </ | ||
- | **Edge** | + | <WRAP boxheader> |
+ | <WRAP boxcontent> | ||
^Name^Description^Value^Space Type^ | ^Name^Description^Value^Space Type^ | ||
|Vertex 1|Index of the first vertex of this edge|Unsigned Short|Grid| | |Vertex 1|Index of the first vertex of this edge|Unsigned Short|Grid| | ||
Line 64: | Line 74: | ||
|Type Number 1|Type to use to cross the edge from the first to the second vertex|Unsigned Short|Grid| | |Type Number 1|Type to use to cross the edge from the first to the second vertex|Unsigned Short|Grid| | ||
|Type Number 2|Type to use to cross the edge from the second to the first vertex|Unsigned Short|Grid| | |Type Number 2|Type to use to cross the edge from the second to the first vertex|Unsigned Short|Grid| | ||
+ | </ | ||
- | **Corner** | + | <WRAP boxheader> |
+ | <WRAP boxcontent> | ||
^Name^Description^Value^Space Type^ | ^Name^Description^Value^Space Type^ | ||
|Vertex|Index of the vertex for this corner|Unsigned Short|Mesh, Volume| | |Vertex|Index of the vertex for this corner|Unsigned Short|Mesh, Volume| | ||
|Type Number|Type to use crossing this edge|Unsigned Short|Mesh| | |Type Number|Type to use crossing this edge|Unsigned Short|Mesh| | ||
</ | </ | ||
+ | </ | ||
+ | |||
<WRAP column 45%> | <WRAP column 45%> | ||
- | **Face** | + | <WRAP boxheader> |
+ | <WRAP boxcontent> | ||
^Name^Description^Value^Space Type^ | ^Name^Description^Value^Space Type^ | ||
|Corner Count|Number of corners in this face|Unsigned Short|Mesh, Volume| | |Corner Count|Number of corners in this face|Unsigned Short|Mesh, Volume| | ||
|Type Number|Type to use moving through this face|Unsigned Short|Mesh| | |Type Number|Type to use moving through this face|Unsigned Short|Mesh| | ||
+ | </ | ||
- | **Wall** | + | <WRAP boxheader> |
+ | <WRAP boxcontent> | ||
^Name^Description^Value^Space Type^ | ^Name^Description^Value^Space Type^ | ||
|Face|Index of the face for this wall|Unsigned Short|Volume| | |Face|Index of the face for this wall|Unsigned Short|Volume| | ||
|Type Number|Type to use crossing this face|Unsigned Short|Volume| | |Type Number|Type to use crossing this face|Unsigned Short|Volume| | ||
+ | </ | ||
- | **Room** | + | <WRAP boxheader> |
+ | <WRAP boxcontent> | ||
^Name^Description^Value^Space Type^ | ^Name^Description^Value^Space Type^ | ||
|Front Wall Count|Number of front facing walls in this room|Unsigned Short|Volume| | |Front Wall Count|Number of front facing walls in this room|Unsigned Short|Volume| | ||
|Back Wall Count|Number of back facing walls in this room|Unsigned Short|Volume| | |Back Wall Count|Number of back facing walls in this room|Unsigned Short|Volume| | ||
|Type Number|Type to use moving through this room|Unsigned Short|Volume| | |Type Number|Type to use moving through this room|Unsigned Short|Volume| | ||
+ | </ | ||
</ | </ | ||
<WRAP clear></ | <WRAP clear></ | ||
- | ===== Navigators ===== | + | ====== Navigators |
- | <WRAP box 250px right :en>{{ :gamedev:images: | + | <WRAP box 250px right :en> |
+ | {{ : | ||
+ | <WRAP centeralign> | ||
+ | </ | ||
While the navigation spaces define the space in which navigation takes pace it is the navigators that determine which path to choose across such a space. Navigators are also also all-round class and can thus be used on all kinds of navigation spaces. To use a navigator you have to first set the **layer number** and the **space type**. The navigator is going to determine a path only using navigation spaces having the same layer and space type. If navigation does not work properly check first if these two parameters are set correctly. Once this is done you can set a **start position** and a **goal position**. Call then **update path**“ and the AI module calculates a path for you. The path is stored as a list of points (DVector) in world space. If no path is found the list of points is 0. Otherwise the list of points defines the path starting with the first path point to head towards. The list does not start with the **start position** but with the first path point. The last point in the list is the **goal position**. The list stays intact until the next time **update path** is called. | While the navigation spaces define the space in which navigation takes pace it is the navigators that determine which path to choose across such a space. Navigators are also also all-round class and can thus be used on all kinds of navigation spaces. To use a navigator you have to first set the **layer number** and the **space type**. The navigator is going to determine a path only using navigation spaces having the same layer and space type. If navigation does not work properly check first if these two parameters are set correctly. Once this is done you can set a **start position** and a **goal position**. Call then **update path**“ and the AI module calculates a path for you. The path is stored as a list of points (DVector) in world space. If no path is found the list of points is 0. Otherwise the list of points defines the path starting with the first path point to head towards. The list does not start with the **start position** but with the first path point. The last point in the list is the **goal position**. The list stays intact until the next time **update path** is called. | ||
- | ==== Cost Functions ==== | + | ===== Cost Functions |
Cost functions allow you to influence the path the AI module calculates for you. As mentioned at the beginning navigation spaces define a **type number** for individual space elements. The navigator stores a list of **Navigation Type** objects. A navigation type stores a **type number**, a **fix cost** and a **cost per meter** parameter. The type number is used to match the navigation type with the navigation space elements. If no match can be found the default parameters for fix cost and cost per meter are used as stored in the navigator. Depending on the navigation space in use the costs are calculated differently using these parameters. **distance** is the distance in meters traveled along a navigation space element. | Cost functions allow you to influence the path the AI module calculates for you. As mentioned at the beginning navigation spaces define a **type number** for individual space elements. The navigator stores a list of **Navigation Type** objects. A navigation type stores a **type number**, a **fix cost** and a **cost per meter** parameter. The type number is used to match the navigation type with the navigation space elements. If no match can be found the default parameters for fix cost and cost per meter are used as stored in the navigator. Depending on the navigation space in use the costs are calculated differently using these parameters. **distance** is the distance in meters traveled along a navigation space element. | ||
Line 108: | Line 131: | ||
<WRAP clear></ | <WRAP clear></ | ||
- | **Example**\\ | + | <WRAP boxheader> |
- | <WRAP box 250px right :en>{{ :gamedev:images: | + | <WRAP boxcontent> |
+ | <WRAP box 250px right :en> | ||
+ | {{ : | ||
+ | <WRAP centeralign> | ||
+ | </ | ||
An example for the use of cost functions is given in the images on the right. The first image shows a sample path through the world. In this case the path leads through the office of a coworker. This is indeed the shortest possible path if we assume doors are automatically opening not hampering your progress. Yet in reality this path is not a realistic one as strolling through an office like that is not considered to be polite. We need thus a way to penalize this route without preventing the path to end up in the office should this be our destination. For this costs functions can be used. In the example the "Type Numbers" | An example for the use of cost functions is given in the images on the right. The first image shows a sample path through the world. In this case the path leads through the office of a coworker. This is indeed the shortest possible path if we assume doors are automatically opening not hampering your progress. Yet in reality this path is not a realistic one as strolling through an office like that is not considered to be polite. We need thus a way to penalize this route without preventing the path to end up in the office should this be our destination. For this costs functions can be used. In the example the "Type Numbers" | ||
- | |||
<WRAP clear></ | <WRAP clear></ | ||
- | <WRAP box 250px right :en>{{ :gamedev:images: | + | |
+ | <WRAP box 250px right :en> | ||
+ | {{ : | ||
+ | <WRAP centeralign> | ||
+ | </ | ||
The first solution using doors requires us to create a " | The first solution using doors requires us to create a " | ||
Line 120: | Line 150: | ||
Which method is the better depends on the situation. The solution with the added fix cost is usually better though as it does not increase the costs too much while still delivering the desired result. | Which method is the better depends on the situation. The solution with the added fix cost is usually better though as it does not increase the costs too much while still delivering the desired result. | ||
<WRAP clear></ | <WRAP clear></ | ||
+ | </ | ||
- | ==== Parameter Summary ==== | + | ===== Parameter Summary |
<WRAP column 45%> | <WRAP column 45%> | ||
- | **Navigator** | + | <WRAP boxheader> |
+ | <WRAP boxcontent> | ||
^Name^Description^Value^ | ^Name^Description^Value^ | ||
|Layer|Layer this navigator uses to find a path|Integer| | |Layer|Layer this navigator uses to find a path|Integer| | ||
Line 131: | Line 163: | ||
|Blocking Cost|Path with costs larger than this value are considered unwalkable|Float| | |Blocking Cost|Path with costs larger than this value are considered unwalkable|Float| | ||
</ | </ | ||
+ | </ | ||
+ | |||
<WRAP column 45%> | <WRAP column 45%> | ||
- | **Navigation Type** | + | <WRAP boxheader> |
+ | <WRAP boxcontent> | ||
^Name^Description^Value^ | ^Name^Description^Value^ | ||
|Type Number|Type number matching this cost function|Unsigned Short| | |Type Number|Type number matching this cost function|Unsigned Short| | ||
|Fix Cost|Fix cost to use|Float| | |Fix Cost|Fix cost to use|Float| | ||
|Cost Per Meter|Cost Per Meter to use|Float| | |Cost Per Meter|Cost Per Meter to use|Float| | ||
+ | </ | ||
</ | </ | ||
<WRAP clear></ | <WRAP clear></ | ||
- | ===== Steering and Collision Avoidance ===== | + | ====== Exporting ====== |
+ | <WRAP box 250px right :en>{{ : | ||
+ | The Blender export scripts provide support to export Mesh objects as Drag[en]gine Navigation Spaces. To mark an object as a navigation space for exporting use the Nav-Space Type property in the Object panel. Only objects with a value other than None are exported in the appropriate format. | ||
+ | <WRAP clear></ | ||
+ | |||
+ | <WRAP box 250px right :en>{{ : | ||
+ | For Mesh and Volume type navigation spaces the Cost type can be defined using the Material each face belongs to. For this use the Navigation Type property in the Material panel. The control provides a soft range from 0 to 10 for quick editing but you can enter any positive integer value including 0. | ||
+ | <WRAP clear></ | ||
+ | |||
+ | For Edges and points as used for Grid navigation spaces it is a bit more complicated due to the nature of how Blender handles custom properties. You have to use Vertex Groups for this to work. Create for each navigation type a single vertex group in the object. | ||
+ | <WRAP center round important 80%> | ||
+ | <WRAP box 250px right :en>{{ : | ||
+ | Once created you can now set the navigation type to use for edges and vertices belonging to a certain vertex group. For this use the Drag[en]gine Vertex Group sub panel in the Mesh Data panel. This shows the navigation data for the active vertex group. If no data has been set yet a button is shown to create the data. Once set the sub panel switches allowing you to set the navigation type the the same way as with materials. Once set you can assign edges and vertices to vertex groups. For a an edge the first vertex group is picked both end point vertices belong to. Hence make sure only one such vertex group fulfills this requirement or the result is undefined. | ||
+ | <WRAP clear></ | ||
+ | |||
+ | |||
+ | |||
+ | ====== Steering and Collision Avoidance | ||
The navigation system provides you only with the path to take along the world. After this task navigation typically consists also of the process of **steering** and **collision avoidance**. These tasks though depend heavily on the game in question and are thus not provided by the AI Module. This is though not a problem since the Physics Module provides you already with collision detection to implement your steering and collision avoidance of choice. | The navigation system provides you only with the path to take along the world. After this task navigation typically consists also of the process of **steering** and **collision avoidance**. These tasks though depend heavily on the game in question and are thus not provided by the AI Module. This is though not a problem since the Physics Module provides you already with collision detection to implement your steering and collision avoidance of choice. |