You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- Match the behavior and property names used in the editor
("Floor/obstacle for pathfinding (navmesh based)", "Max. speed",
"Rotation speed"...).
- Explain that objects can be walkable floors in 3D, and how the walkable
area is defined in 2D.
- Mention the "Y speed scale" scene property for isometric games.
- Fix the reference page link.
The **Pathfinding**behavior allows to move objects to a selected destination as well as to flag items as obstacles. Objects that are flagged as obstacles will be avoided by the moving objects.
6
+
The **navmesh pathfinding**behaviors move objects to a destination by following walkable floors and going around obstacles. They work in 2D and in 3D, and a whole crowd of characters can move at the same time while avoiding each other.
7
7
8
-
## Choose which objects to avoid
8
+
## Choose the floors and the obstacles
9
9
10
-
By using the **Obstacle for Pathfinding (navmesh-based)**[behavior](/gdevelop5/behaviors), you can flag any [object](/gdevelop5/objects) to be an obstacle.
10
+
By using the **Floor/obstacle for pathfinding (navmesh based)**[behavior](/gdevelop5/behaviors), you can flag any [object](/gdevelop5/objects) as a walkable floor, as an obstacle, or as both.
11
+
12
+
In 3D, characters walk on the flat surfaces of these objects and go around the steep ones. Add the behavior to the floors and platforms where characters must walk, and to the walls and props they must avoid.
13
+
14
+
In 2D, objects with this behavior are always obstacles. Characters can only move inside the rectangle that contains all of them, so put obstacles around the area where characters can go.
11
15
12
16
When the behavior is added to an object, some properties can be modified:
13
17
@@ -16,31 +20,31 @@ When the behavior is added to an object, some properties can be modified:
16
20
These properties are only relevant for [3D model](/gdevelop5/objects/3d-model) objects. The 2D collision mask is always used for 2D objects.
17
21
18
22
***Shape** – You can choose between using the model shape (**Mesh**) or a bounding box (**Box**).
19
-
***Simplified 3D model** – Models with a lot of polygons can require heavy computations. You can make a simplified version of your model with an external tool and add it in this property to make the obstacle faster to compute.
23
+
***Simplified 3D model** – Models with a lot of polygons can require heavy computations. You can make a simplified version of your model with an external tool and set it in this property to make the obstacle faster to compute.
20
24
21
25
!!! tip
22
26
23
-
If you need objects to move in only 4 or 8 direction, you can use the [grid-based pathfinding](/gdevelop5/behaviors/pathfinding) instead.
27
+
If you need objects to move in only 4 or 8 directions, you can use the [grid-based pathfinding](/gdevelop5/behaviors/pathfinding) instead.
24
28
25
29
!!! note
26
30
27
-
[Tile maps](/gdevelop5/objects/tilemap) can also be used as obstacles: add the **Obstacle for Pathfinding (nav-mesh based)** behavior to a tile map that has collisions, and the moving objects will avoid its tiles.
31
+
[Tile maps](/gdevelop5/objects/tilemap) can also be used as obstacles: add the **Floor/obstacle for pathfinding (navmesh based)** behavior to a tile map that has collisions, and the moving objects will avoid its tiles.
28
32
29
33
## Move objects while avoiding obstacles
30
34
31
-
The **Pathfinding character (navmesh-based)** behavior allows to compute the shortest path from the object to a destination, and optionally move the object to this destination, while avoiding all objects that have the **Obstacle for Pathfinding (navmesh-based)** behavior.
35
+
The **Pathfinding character (navmeshbased)** behavior computes the shortest path from the object to a destination and, optionally, moves the object along this path, while avoiding all the objects that have the **Floor/obstacle for pathfinding (navmeshbased)** behavior.
32
36
33
37
After adding the behavior to the object, you can customize some properties:
***Radius** – The half-size of the character. This setting determines how close the object can move to obstacles.
41
+
***Acceleration** – How fast the object accelerates while moving on a path.
42
+
***Max. speed** – The maximum speed the object can reach on the path.
38
43
***Avoidance sight range** – How far ahead the character looks to avoid other characters.
39
-
***Acceleration** – How fast the object is going to accelerate while moving on a path.
40
-
***Max speed** – Maximum speed the object can move on the path.
41
-
***rotate object** – If you don't want the object to rotate while moving on the path, disable the object's rotation.
42
-
***Rotate speed** – The speed of the object's rotation.
43
-
***Angle offset** – In case the sprite is facing the wrong direction, you can fix it with the angle offset
44
+
***Radius** – The radius of the character. This setting determines how close the object can move to obstacles.
45
+
***Angle offset** – In case the sprite is facing the wrong direction, you can fix it with the angle offset.
46
+
***Rotation speed** – The speed of the object's rotation.
47
+
***Rotate object** – Disable it if you don't want the object to rotate while moving on the path.
44
48
45
49
!!! note
46
50
@@ -58,30 +62,34 @@ or in 3D (using the [3d raycast](/gdevelop5/extensions/raycaster3d) extension):
58
62
59
63
!!! warning
60
64
61
-
The **Move to a position** action only needs to be run once. If you run this action without any condition, it will try to compute the path at every frame. This will generate a lot of intensive computations for your device. You can add the **Destination reached** condition or use a [timer](/gdevelop5/all-features/timers-and-time) to solve this.
65
+
The **Move to a position** action only needs to be run once. If you run this action without any condition, it will compute the path at every frame, which is very demanding for the device. You can add the **Destination reached** condition or use a [timer](/gdevelop5/all-features/timers-and-time) to solve this.
66
+
67
+
!!! tip
68
+
69
+
In an isometric 2D game, set the **Y speed scale** scene property to `0.5` so that characters move slower vertically than horizontally.
62
70
63
-
## Avoid frame skipping when modifying obstacle
71
+
## Avoid frame skipping when obstacles change
64
72
65
-
When obstacles are moved, created, deleted or their behavior is deactivated or activated back, the navigation mesh is updated for the next frame and it can take more than 1/60 second which leads to frame skipping.
73
+
When obstacles are moved, created or deleted, or when their behavior is deactivated or activated again, the navigation mesh is rebuilt on the next frame. This can take more than 1/60 of a second, which leads to frame skipping.
66
74
67
75
You can reduce this side effect by:
68
76
69
77
- Making **Cell size** and **Cell depth** bigger in the scene properties.
70
-
- Setting a **Simplified 3D model** for obstacles that use a **Mesh** shape. The simplified model should have the least amount of polygons possible. For instance, a ramp often only need 5 faces.
71
-
- Making a chunk system that destroys obstacles that are faraway by batch.
78
+
- Setting a **Simplified 3D model** for obstacles that use a **Mesh** shape. The simplified model should have as few polygons as possible. For instance, a ramp often only needs 5 faces.
79
+
- Making a chunk system that destroys far away obstacles in batches.
72
80
73
81
## Troubleshoot navigation mesh generation
74
82
75
-
You can display the generated navigation mesh with the **Draw pathfinding walkable area** action.
83
+
You can display the generated navigation mesh with the **Draw pathfinding walkable area** action. The walkable area is drawn in blue.
76
84
77
85

78
86
79
87
Try to modify the following scene properties and check the effects on the navigation mesh by running a preview:
80
88
81
-
***Max. stair height** – If characters won't climb stairs, try with a greater value.
82
-
***Slope max. angle** – If characters won't walk on steep slopes, try with a greater value.
83
-
***Walkable depth** – If characters won't go under a roof, try with a smaller value.
84
-
***Walkable radius** – If characters won't go on a tight way, try with a smaller value. It's usually better to keep it automatic (`-1`) and change the **Radius** on characters.
89
+
***Max. stair height** – If characters won't climb stairs, try a greater value.
90
+
***Slope max. angle** – If characters won't walk on steep slopes, try a greater value.
91
+
***Walkable depth** – If characters won't go under a roof, try a smaller value.
92
+
***Walkable radius** – If characters won't go through a narrow passage, try a smaller value. It's usually better to keep it automatic (`-1`) and change the **Radius** on characters.
85
93
86
94
{ width="382" }
87
95
@@ -100,4 +108,4 @@ Try to modify the following scene properties and check the effects on the naviga
100
108
101
109
## Reference
102
110
103
-
All actions, conditions and expressions are listed in [the nav-mesh pathfinding reference page](/gdevelop5/all-features/nav-mesh-pathfinding-behavior/reference/).
111
+
All actions, conditions and expressions are listed in [the navmesh pathfinding reference page](/gdevelop5/all-features/nav-mesh-pathfinding/reference/).
Copy file name to clipboardExpand all lines: docs/gdevelop5/behaviors/pathfinding/index.md
+8-8Lines changed: 8 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,11 +3,11 @@ title: Grid-based pathfinding
3
3
---
4
4
# Grid-based pathfinding
5
5
6
-
The **Pathfinding**behavior allows to move objects to a selected destination as well as to flag items as obstacles. Objects that are flagged as obstacles will be avoided by the moving objects.
6
+
The **grid-based pathfinding**behaviors move objects to a selected destination and flag items as obstacles. Objects that are flagged as obstacles will be avoided by the moving objects.
7
7
8
-
## Choose which objects to avoid: the "Obstacle for Pathfinding" behavior
8
+
## Choose which objects to avoid
9
9
10
-
By using the **Obstacle for Pathfinding (grid-based)**[behavior](/gdevelop5/behaviors), you can flag any [object](/gdevelop5/objects) to be an obstacle.
10
+
By using the **Obstacle for pathfinding (grid-based)**[behavior](/gdevelop5/behaviors), you can flag any [object](/gdevelop5/objects) to be an obstacle.
11
11
12
12
When the behavior is added to an object, some properties can be modified:
13
13
@@ -18,15 +18,15 @@ When the behavior is added to an object, some properties can be modified:
18
18
19
19
!!! tip
20
20
21
-
Obstacles may take more space than expected because a box around obstacles is used instead of the [collision mask](/gdevelop5/objects/sprite/collision-mask). The [navigation mesh pathfinding](/gdevelop5/behaviors/nav-mesh-pathfinding) can be used instead to solve this.
21
+
Obstacles may take more space than expected because a box around obstacles is used instead of the [collision mask](/gdevelop5/objects/sprite/collision-mask). You can use the [navigation mesh pathfinding](/gdevelop5/behaviors/nav-mesh-pathfinding) instead to solve this.
22
22
23
23
!!! note
24
24
25
-
[Tile maps](/gdevelop5/objects/tilemap) can also be used as obstacles: add the **Obstacle for Pathfinding (grid-based)** behavior to a tile map that has collisions, and the moving objects will avoid its tiles.
25
+
[Tile maps](/gdevelop5/objects/tilemap) can also be used as obstacles: add the **Obstacle for pathfinding (grid-based)** behavior to a tile map that has collisions, and the moving objects will avoid its tiles.
26
26
27
27
## Move objects while avoiding obstacles
28
28
29
-
The **Pathfinding character (grid-based)** behavior allows to compute the shortest path from the object to a destination, and optionally move the object to this destination, while avoiding all objects that have the **Obstacle for Pathfinding (grid-based)** behavior.
29
+
The **Pathfinding character (grid-based)** behavior computes the shortest path from the object to a destination and, optionally, moves the object along this path, while avoiding all the objects that have the **Obstacle for pathfinding (grid-based)** behavior.
30
30
31
31
After adding the behavior to the object, you can customize some properties:
32
32
@@ -45,7 +45,7 @@ After adding the behavior to the object, you can customize some properties:
45
45
46
46
!!! note
47
47
48
-
A smaller cell size implies more computations so try to still keep the size as large as possible.
48
+
A smaller cell size implies more computations, so try to keep the size as large as possible.
49
49
50
50
To initiate a pathfinding move, add the action **Move to a position** and specify the location you want the object to move to.
51
51
It will move using the characteristics defined in the behavior properties.
@@ -55,7 +55,7 @@ If you want to change how the object moves during the game, these properties can
55
55
56
56
!!! warning
57
57
58
-
The **Move to a position** action only needs to be run once. If you run this action without any condition, it will try to compute the path at every frame. This will generate a lot of intensive computations for your device. You can add the **Destination reached** condition or use a [timer](/gdevelop5/all-features/timers-and-time) to solve this.
58
+
The **Move to a position** action only needs to be run once. If you run this action without any condition, it will compute the path at every frame, which is very demanding for the device. You can add the **Destination reached** condition or use a [timer](/gdevelop5/all-features/timers-and-time) to solve this.
0 commit comments