Hi all, I made a post about Astar yesterday, but I found where my issue is so I want to make a new post about specifically that problem.
I have areas of my game where there are separated sections in the navigation. No connections between the areas, but the player can still go between both. There's a gate object that is used to go between the two locations. The red cubes are locations on the astar grid.
When I click on the gate object, it finds the nearest node in the astar grid. But the problem I have is that when I run the code, it always returns the same node. So if I am on one side of the gate, I can get a path to the selected node, but if I'm on the other side of the gate, there is no way to get a path to that node. So it returns an empty path. So I need to figure out how to loop through nodes if a path can't be returned, and I am not quite sure how to do that.
`func get_pathway(start, end):
var gm_start = v3_to_index(navigation_map.local_to_map(start))
var gm_end = v3_to_index(navigation_map.local_to_map(end))
var start_id = 0
var end_id = 0
if gm_start in all_points:
start_id = all_points[gm_start]
else:
start_id = astar.get_closest_point(start)
if gm_end in all_points:
end_id = all_points[gm_end]
else:
end_id = astar.get_closest_point(end)
return astar.get_point_path(start_id, end_id)`
in the "if gm_end in all_points", how would I loop through all nodes that are within 1 space? That way I can loop through them and check for a path, then return that path.