Hi there, im trying to write down a mob spawn script (wave style).
and this is what i came up with :
func _on_enemy_spawn_timer_timeout():
var enemy1_count = get_node(".").get_child_count()
var loop_count = 0
if enemy1_count < 5 :
loop_count = loop_count + 1
for c in range(1):
random_x.randomize()
var random_x_number = random_x.randf_range(-20,20)
random_y.randomize()
var random_y_number = random_y.randf_range(1,1)
random_z.randomize()
var random_z_number = random_z.randf_range(-20,20)
var gem_instance = preload ("res://sahneler/gem.tscn").instance()
add_child(gem_instance)
add_to_group("gems")
gem_instance.set_translation(Vector3(random_x_number,random_y_number,random_z_number))
print (enemy1_count)
print (loop_count)
well this is works actualy, but there is a huge flaw in it, this code spawn enemys one by one
(every 0.5 second, one enemy spawned).
but after i kill one enemy, script fill the hole and spawn another one, make it 5 again.
but what i want is, control over how many enemy spawned in each wave.
for example, in this script, i wanna only 5 enemy spawned, after all of them killed, there will be new wave, and that wave will have 10 enemy etc.
i try to count each loop and try to break after 5 enemy spawned, but, bruh... im noob, and need help.
this is how it looks like:

Sory for the bad English, im not native speaker.
Thank you as always.