Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
gdevelop5:behaviors:pathfinding [2018/09/26 23:36]
valiant_curiosity [Add behaviour to object]
gdevelop5:behaviors:pathfinding [2019/05/29 12:05] (current)
akbarhabeebb [Option 2: Pathfinding Obstacle behavior] Typo
Line 1: Line 1:
 #​Pathfinding #​Pathfinding
  
-Pathfinding behavior ​allows us to move objects to a selected destination as well as to flag items as obstacles that are going to be avoided by the moving objects.+**[[#​Examples|I would rather see the Pathfinding behavior ​examples! Please take me there now.]] 
 +**
  
-## Examples ​+Pathfinding behavior allows us 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.
  
-<note tip>​**See it in action!** 🎮\\ +## Add behavior to object 
-Open these examples online.</​note>​+To add behavior to an object, as usual, create the object. Then open the object'​s properties by right-clicking on the Objects list located on the right of the Scene Interface. Select "Edit object"​ from the popup list
  
-* https://​editor.gdevelop-app.com/?​project=example://​pathfinding +{{:​gdevelop5:​editplayerobject.jpg?​200|}}
-* https://​editor.gdevelop-app.com/?​project=example://​pathfinding-basics +
- +
-## Add behaviour to object +
-To add behavior to an object, first open the object'​s properties by right clicking on the scene object. Select "Edit object"​ from the popup list. (You can also select the object from the Objects menu.)  +
- +
-{{:​gdevelop5:​editplayerobject.jpg?​400|}}+
  
 Now, select the behavior tab and click the "add behavior"​ button. ​ Now, select the behavior tab and click the "add behavior"​ button. ​
Line 25: Line 20:
 {{ :​gdevelop5:​behaviors:​pathfinding-behavior-inlist.png?​nolink |}} {{ :​gdevelop5:​behaviors:​pathfinding-behavior-inlist.png?​nolink |}}
  
-Pathfinding behavior ​allow us to move the object to a destination while it is going to avoid all objects flagged as obstacle. ​+"Pathfinding behavior" allows ​us to move the object to a destination while avoiding ​all objects flagged as an obstacle. ​
  
-After we add the behaviour to the object, we can customize number of options+After we add the behaviour to the object, we can customize ​number of options.
 {{ :​gdevelop5:​behaviors:​pathafindin-behavior-options.png?​nolink |}} {{ :​gdevelop5:​behaviors:​pathafindin-behavior-options.png?​nolink |}}
  
-  * **acceleration:​** this is how fast our object going to accelerate while moving on a path +  * **acceleration:​** this is how fast our object ​is going to accelerate while moving on a path. 
-  * **allow diagonals:​** ​is the object can move in diagonals ​or not +  * **allow diagonals:​** ​test whether or not the object can move in diagonals. 
-  * **angle offset:** in case our sprite facing the wrong direction we can set the angle offset +  * **angle offset:** in case our sprite ​is facing the wrong direction we can set the angle offset 
-  * **extra border size:** border size around the object ​to set how close the object can move to the obstacles +  * **extra border size:​** ​sets the border size around the object. This setting determines ​how close the object can move to the obstacles. 
-  * **max speed:** maximum speed the object can move on the path +  * **max speed:** maximum speed the object can move on the path. 
-  * **rotate object:​** ​disable ​if you don't want the object to rotate while moving on the path +  * **rotate object:** if you don't want the object to rotate while moving on the path, disable the object'​s rotation. 
-  * **rotate speed:** speed of rotation +  * **rotate speed:​** ​sets the speed of the object'​s ​rotation. 
-  * **virtual cell height and width:** our path is generated using a virtual grid, we can change the size of the cells here, the smaller the size is, the smoother the movement is going to be. A smaller size implies more calculations so try to still keep size as large as possible.+  * **virtual cell height and width:** our path is generated using a virtual grid. We can change the size of the cells here, the smaller the cell size, the smoother the movement is going to be. //A smaller ​cell size implies more calculations so try to still keep the size as large as possible.//
  
-## PathfindingObstacle ​behavior+## Option 2: Pathfinding Obstacle ​behavior
 {{ :​gdevelop5:​behaviors:​pathfinding-obstacle-inlist.png?​nolink |}} {{ :​gdevelop5:​behaviors:​pathfinding-obstacle-inlist.png?​nolink |}}
  
-By using the pathfinding ​obstacle behavior we can flag any object to be an obstacle.  +By using the "​Pathfinding ​obstacle behavior", ​we can flag any object to be an obstacle.  
-After we add the behavior to the object we have two options to customize:+After we add the behavior to the objectwe have two options to customize:
 {{ :​gdevelop5:​behaviors:​pathfinding-obstacle-options.png?​nolink |}} {{ :​gdevelop5:​behaviors:​pathfinding-obstacle-options.png?​nolink |}}
  
-  * **impassable:​** if we enable this the obstacle is going to be impassable ​and the moving object is going to avoid it at all cost. +  * **impassable:​** if we enable thisthe obstacle is going to be impassable. The moving object is going to avoid it at all cost. 
-  * **cost:​** ​in case the obstacle is not impassable, we can set a cost for the obstacle. The moving object, when looking for the best possible path to a destination,​ is going to prefer to avoid the obstacle with high cost values. For example, a river might have some cost so that the moving object ​is going to avoid it if possible, ​but in case there is no other way around the river, or if the river has a lower cost compared to another area, the moving object will go through it (instead of climbing a mountain with a higher cost for example). And if we put crocodiles into the river and increase its cost, the moving object might decide to climb the mountains instead.+  * **cost:​** ​if the obstacle is not impassable, we can set a cost for the obstacle. The moving object, when looking for the best possible path to a destination,​ is going to prefer to avoid the obstacle with high-cost values. For example, a river might have some cost. The moving objectif possible, ​ will avoid it. However, if there is no other way around the river, or if the river has a lower cost compared to another area, the moving object will go through it (instead of climbing a mountain with a higher cost for example). And if we put crocodiles into the river and increase its cost, the moving object might decide to climb the mountains instead. 
 + 
 +## Examples  
 + 
 +<note tip>​**See it in action!** 🎮\\ 
 +Open these examples online.</​note>​ 
 + 
 +**General Path Finding Behavior** 
 + 
 +[[https://​editor.gdevelop-app.com/?​project=example://​pathfinding|{{:​gdevelop5:​behaviors:​pathfindinggeneral.png?​200|}}]] 
 + 
 +* https://​editor.gdevelop-app.com/?​project=example://​pathfinding 
 + 
 +**Path Finding Basics** 
 + 
 +[[https://​editor.gdevelop-app.com/?​project=example://​pathfinding-basics|{{:​gdevelop5:​behaviors:​pathfindingbasics.png?​200|}}]] 
 + 
 +* https://​editor.gdevelop-app.com/?​project=example://​pathfinding-basics