Pathfinding behavior and obstacle

There are some questions about:

  • Angle offset
  • Extra border size
  • Virtual cell height/width

Pathfinding obstacle

What’s the question.

What are these?
I need some explaination about those i wrote.

Those are not clear questions, but i will try my best to interpret it. Pathfinding allows an object to move from one location to another while avoiding any location marked as blocked. This works thanks to a virtual grid and the pathfinder obstacle behavior: any object with that behavior will mark the cells of the virtual grid it touches as blocked. Objects with the pathfinding behavior will then search for the fastest way to go from the cell the object is on to the cell of the position selected while avoiding the blocked cells. The virtual grid system is needed to keep the algorithm performant.

Cost is often used in games to tell how much something is causing lag, as performance is seen as a resource you have a certain budget of and you cannot afford too many “expensive” functions to be used to keep your game in that budget (playable without lag).


@arthuro555 Thank you

In case of Pathfinding Obstacles the “Cost” means how difficult it is to get through the obstacle in case the obstacle is NOT impassable. Higher the value the more difficult it is to get through. The pathfinding algorithm going to try to find a way though the obstacles with less cost. So for example, a dirt road in the game might have higher cost than a concrete road and pathfinding going to try to find a path on the concrete road in the first place, but in case can not find a path on a concrete road, it is going to find a path on a dirt road but movement is going to be slower on the dirt road as it has higher cost.

Angle offset:
In the pathfinding properties, you can select the object to always face to direction of movement However in GDevelop the graphics need to be facing right (0 degree or 360) in order for this feature to work properly. In case your graphics is different and facing down (90 degrees) for example, instead of editing the image in an image editor to face right, you can apply offset of -90 to make it work with the pathfinding and always face the direction of movement.

Extra border size:
As the pathfinding algorithm looking for a path, it may not take in to account the actual size of the object moving on the path and the object be able to move through small gaps that is just looks wrong. In order to avoid that, you can apply extra border to avoid the pathfinding algorithm move the object through small gaps.

Virtual Cell width and height
The pathfinding algorithm, is dividing the scene in to a virtual grid as arthuro555 mentioned, the size of each individual cell in the grid is determine how accurate the path is going to be. Setting the size smaller going to result in much more smooth and accurate navigation meaning objects going to take less unnecessary turns and can use space more efficiently but may going to have high impact on performance. Setting the cell size higher going to result in less accurate navigation meaning, objects may take unnecessary turns, often seemingly for no reason far away from the obstacle and even if there is enough space, objects may go around if the cell size is too big but it is going to have less impact on performance.

You can find all this information on the wiki.

It is okay to ask If you still don’t understand something after reading the wiki but make sure you actually write a sentence to ask a question. If all you write is Question - Cell and don’t even put the effort in to writing a sentence to ask your question, your topic may going to be ignored or even considered a spam and locked. You were lucky arthuro555 was in a good mood and did not locked your topic straight away.

Hope it helps.