var astar = AStar2D.new() astar.add_point(1, Vector2(0, 0)) astar.add_point(2, Vector2(0, 1), 1) # Default weight is 1 astar.add_point(3, Vector2(1, 1)) astar.add_point(4, Vector2(2, 0))
astar.connect_points(1, 2, false) astar.connect_points(2, 3, false) astar.connect_points(4, 3, false) astar.connect_points(1, 4, false)
var res = astar.get_id_path(1, 3) # Returns 1, 2, 3
If you change the 2nd point's weight to 3, then the result will be $(D 1, 4, 3) instead, because now even though the distance is longer, it's "easier" to get through point 4 than through point 2.
Returns an array with the IDs of the points that form the path found by AStar2D between the given points. The array is ordered from the starting point to the ending point of the path.