Why is my "get_point_path()" returning empty

Godot Version
4.4

I am working on movement in a turn-based game. I want this function to loop through each enemy, generate paths to each party character and then feed the shortest path to the physics process. The positions come out correct, but the path is always empty.

(3, 3)pos2
(7, 1)dest2
Cells =
Cells2 =

The above is an example of what comes out in the terminal. Am I missing something? I even set up a standalone function to test coordinate pairs. The below function will create an actual path:

func move_test():
	setup_grid()
	print("move test"+str(astar_grid.get_point_path(Vector2i(3,3), Vector2i(7,1))))

Here is the movement function:


func enemy_move():
	move_test()
	setup_grid()
	var enemy_zone = get_tree().get_nodes_in_group("Enemies")
	var friend_array = get_tree().get_nodes_in_group("Friendlies")
	print(enemy_zone)
	print("friends"+str(friend_array))
	for enemy in enemy_zone:
		print("enemy_pos"+str(enemy.position))
		var orig_posish = enemy.position
		var enemy_move = enemy.attribute_dict["movement"]
		var target_array = []
		var path_list = []
		var enemy_path_temp = []
		
		for friendly in friend_array:
			target_array.append(friendly.position)
		for target in target_array:
			print("target = "+str(target))
			var pos_A = Vector2i(orig_posish.x/movement_multiplier, orig_posish.y/movement_multiplier)
			var dest_B = Vector2i(target.x/movement_multiplier, target.y/movement_multiplier)
			var cellsB = astar_grid.get_point_path(pos_A,  dest_B)
			for cell in cellsB:
				enemy_path_temp.append(cell)
			print(str(pos_A) +"pos2")
			print(str(dest_B) +"dest2")
			print("Cells = "+ str(cellsB))
			print("Cells2 = "+ str(enemy_path_temp))
			if len(path_list) == 0:
				path_list.append(cellsB)
			if len(path_list) > 0:
				if len(path_list[0]) > len(cellsB):
					path_list = [cellsB]
			for i in range(enemy_move):
				pass
				#enemy_path_temp.append(cells2[i])
			enemy_path.append(enemy_path_temp)
			enemies_selected.append(enemy)

Your move_test works before setup_grid(), so problem inside setup_grid()

1 Like