Hey, i think i solved this:
The problem is not that the enemies don't spawn... the problem is that your script does not detect the correct formation, so it does not move them, so they stay out of screen and you don't see them.
Why is this happening? Because you relay of the 3 leftmost characters of the parent node to see the formation; you are doing this:
func _ready():
current_formation = get_parent().name.left(3)
add_to_group("enemy")
_process(true)
pass
func _process(delta):
#Straight top to bot formation
if current_formation == ("as1"):
self.position += toptobot_direction * speed
print (position.y)
if self.position.y == 680:
queue_free()
The first problem i noticed here is that you are checking for position.y exactly equal to 680 to free the enemies... this may not happen, because perhaps in one frame position is 679 and in the next 681 and you skipped 680, so you are not freeing the enemy. The second problem is that you rely on the 3 leftmost characters of the parents name to get the formation. BUT... as names are unique, when you instance another enemy, if there is a previous one alive, godot will change the name to "@as1...", so the 3 leftmost characters would be "@as" and you dont get the formation. I solved all of this with this:
func _ready():
current_formation = get_parent().name
add_to_group("enemy")
_process(true)
pass
func _process(delta):
#Straight top to bot formation
if "as1" in current_formation:
self.position += toptobot_direction * speed
print (position.y)
if self.position.y >= 680:
queue_free()
Notice i changed if self.position.y == 680:
by if self.position.y >= 680
; also changed current_formation = get_parent().name.left(3)
by current_formation = get_parent().name
and at last i changed if current_formation == ("as1"):
by if "as1 in current_formation:
.
Hope it helps!