Hi all, if I add to my 'obstacles' array like so:

``````obstacles = []
obstacles = get_used_cells_by_id(13)
``````

then the astar implementation I'm studying works.

However, if I add like the following:

``````obstacles = []
obstacles.push_back(get_used_cells_by_id(13))
obstacles.push_back(get_used_cells_by_id(14))
obstacles.push_back(get_used_cells_by_id(15))
obstacles.push_back(get_used_cells_by_id(16))
``````

then the astar doesn't walk around those obstacles.

This is the astar fuction:

``````func astar_add_walkable_cells(obstacles = []):
print("obstacles - ", obstacles)
var points_array = []
for y in range(map_size.y):
for x in range(map_size.x):
var point = Vector2(x, y)
if point in obstacles:
print("obstacle")
continue

points_array.append(point)
# The AStar class references points with indices
# Using a function to calculate the index from a point's coordinates
# ensures we always get the same index with the same input point
var point_index = calculate_point_index(point)
# AStar works for both 2d and 3d, so we have to convert the point
# coordinates from and to Vector3s
return points_array
``````

What would make the astar not use my obstacle when added via a push_back VS a singular assignment?

Thanks so much...

UPDATE The following code works. But why? Surely a push_back would work?

``````obstacles = obstacles + get_used_cells_by_id(10)
obstacles = obstacles + get_used_cells_by_id(11)
obstacles = obstacles + get_used_cells_by_id(12)
obstacles = obstacles + get_used_cells_by_id(13)
obstacles = obstacles + get_used_cells_by_id(14)
``````
in Engine
edited