Sabir what I would do is set an export variable for frames, as in how many frames you want to pass before you can fire a bullet, along with a bool that determines whether or not you can fire. The bool flips to false when you fire and that resets your total for the frames. Then when you fire, bool flips off and frames start "draining".
You could also use a timer and have the bool flip every timeout, and start the timer after you shoot. EITHER WAY, only allow a shoot function whenever the bool is flipped.
var _canFire = true ## if off, can't shoot
export var _fireFramesMax = 50 ## a base value for the timer to fill
export var _fireRate = 1 ## the "rate" the frames drain (if not using timer)
var _fireFramesCurrent = _fireFramesMax ## frames until next shot (only if not using timer)
func _process(_delta):
if _canFire:
_shoot( )
else:
_fireFramesCurrent - _fireRate
if _fireFramesCurrent <= 0:
_canFire = true
_fireFramesCurrent = _fireFramesMax
OR the easier way with a timer and you don't need to track current time frames.
add $Timer.start(_fireFramesMax) to your shoot function along with _canFire = false when you shoot.
Then connect the Timer signal and do a similar process logic function, though as you can see, this is easier.
func _process(_delta):
if _canFire:
_shoot( )
func _on_Timer_timeout(_):
_canFire = true