Right now this code works with "single fire and single fire sound loop" only. If I switch to auto fire and switch the sound loop to auto fire gun and hold the fire button the sound loop finishes but the bullets keep firing. My question is what line of code in the ********************** area can I put in so the bullets will stop firing after the sound loop finishes so the reload timer and reload soundloop starts. Thank you
func _ready() -> void:
delay_timer = Timer.new()
if autofire:
delay_timer.connect("timeout", self, "_fire")
else:
delay_timer.connect("timeout", self, "_reload")
add_child(delay_timer)
fire_sound_player = AudioStreamPlayer.new()
fire_sound_player.stream = fire_sound
add_child(fire_sound_player)
reload_sound_player = AudioStreamPlayer.new()
reload_sound_player.stream = reload_sound
add_child(reload_sound_player)
func _fire() -> void:
if bullet_res != null:
can_fire = false
var new_bullet = bullet_res.instance()
add_child(new_bullet)
new_bullet.fire(muzzle_velocity)
*****************************
delay_timer.start(fire_delay)