Hi,
I have a Navigation2D node with two tilemap childs, tileMap
and tileMap_Selection
.
The idea was to try and find the shortest path from one tile to another, the tileMap
doesn't have any navigation2D_polygon
so I set all the tiles in tileMap_Selection
to a tile which has a navigation2D_polygon
.
If i set all tiles and then straight away ask for a path from one tile to another the resulting list of points is empty but if I wait for 0.1 seconds the list contains all points.
On the parent Navigation2D i have a script which has the following code:
func findTiles():
var potentialTiles = tileMap.get_used_cells()
for tile in potentialTiles:
tileMap_selection.set_cellv(tile, 1)
#yield(get_tree().create_timer(0.1), "timeout")
print(get_simple_path(tileMap_selection.map_to_world(potentialTiles[0]), tileMap_selection.map_to_world(potentialTiles[1]), false))
with yield(get_tree().create_timer(0.1), "timeout")
commented the output is []
whereas if it is uncommented the output is: [(4284, -88), (4391.5, 67.5), (4533, 126), (4536, 44)]
Is there a better was than to use yield(get_tree().create_timer(0.1), "timeout")
in order for the get_simple_path
function to use the updated tileMap_selection ?
Thanks a lot for any help you can provide,