So I’m making a side scrolling shoot 'em up. I was able to make code for firing that works really well, but the problem is, it only fires each time the button is pressed. As a result, one would have to rapidly press the fire button to shoot lots of times in a row. I’m wondering what would be the easiest way to allow the player to hold the fire button to fire a continuous stream of projectiles.
The code I have for shooting is as follows, with this simply being the basic attack without any weapon upgrades:
if Input.is_action_just_pressed("action_shoot") and akane_upgrade == 0:
var new_proj1 = proj1.instantiate()
new_proj1.global_position = $Main_Gun.global_position
add_sibling(new_proj1)
In _process(delta) function:
if Input.is_action_pressed(“fire”):
Connect “Input.is_action_pressed” signal and place in _process. It should execute each tick allowing continuous fire as long as the action button of choice is being pressed. Just plop your firing code below the is action pressed signal.
So I tried your idea, and it works. However, is there a way to space out how frequently it’s fired with your method? Because right now it fires as a continuous stream.