Tilemap Pathfinding

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Majesty
:warning: Old Version Published before Godot 3 was released.

I’m creating top down game with tile based movement, and I want to add the possibility to move to a position by clicking the mouse button. To do so, I created a function which take an array of directions and follow the path.

I’m using the Navigation2D node to make the pathfinding (I added the tilemap as a child of the Navigation2D) and get the position array, but the points doesn’t seems to be correct.

Here is an example:
enter image description here

I’m using this simple function:
var points = navigation.get_simple_path(position, destination, false)

If I click on the marked tile, here is what points contains :enter image description here

With a tile size of 32px, I don’t understand why each position is incremented by 16px.

Also if I click on the tile just to the right of this one, here is what I get :enter image description here

It seems to make a diagonal movement, but it’s probably intented ?

Finally, here is how I created the NavigationPolygonInstance in the Tileset, because it may be related to this :
enter image description here

I think I don’t understand how the Navigation2D works, what am I doing wrong ?

Only need change false to true:

var points = navigation.get_simple_path(position, destination, true)

neoloopy | 2018-08-10 23:59

:bust_in_silhouette: Reply From: NVA_Lee22

Maybe this can help you ?


Edit: Maybe this is the same issue that you have?

In this video you can see demonstration of above mentioned approach:

pospathos | 2017-07-11 10:21