i have this script to make a list of player's unit and enemy's unit, every time a unit is spawn or destroyed this function run again to update the list and reconnect the signals but...
func set_targets()-> void:
var nodos:Array = get_children()
player_units.clear()
enemy_units.clear()
for element in nodos:
if element.is_in_group("player"):
player_units.push_front(element)
element.connect("player_unit_destroyed",self,"handle_destroy_unit")
if element.is_in_group("enemy"):
lvl_top_score += element.score
enemy_units.push_front(element)
element.connect("enemy_unit_destroyed",self,"handle_destroy_enemy")
for element in player_units:
element.set_targets_to_attack(enemy_units.duplicate(true))
i keep getting this error:
E 0:00:27.932 connect: Signal 'enemy_unit_destroyed' is already connected to given method 'handle_destroy_enemy' in that object.
Method failed. Returning: ERRINVALIDPARAMETER
core/object.cpp:1512 @ connect()
devlvlcombat.gd:55 @ settargets()
devlvl1.gd:111 @ _onTimer2timeout()
so i want to check if they are already connected. But i don't find the way.