Can someone help a newbie out? My game is crashing after a few shots because of this code. I have a timer node named "shot_timer" set to autostart and 1 second.
func ontimertimeout():
var times = [1,2,3]
var shots = 0
var cooldown = randrange(1,3)
while shots!= times[randi() % times.size()]:
var laser = scn_laser.instance()
laser.set_position($cannon.get_global_position())
get_tree().get_root().call_deferred("add_child",laser)
AudioPlayer.play_sample("laser_enemy")
$shot_timer.set_wait_time(cooldown)
shots += 1
I have been using yields with one shot timers, but was getting errors and was told to use timers instead. Thought they would be easier to use...
Thanks in advance.