- Edited
So, I need some help on adding a firing rate on my projectiles in my game. Here is my code for firing bullets
func shoot():
if charge < 4:
var bullet_uncharged = load("res://Scenes/Bullets/Bullet_Uncharged.tscn")
var bullet = bullet_uncharged.instantiate()
bullet.position = get_global_position()
get_parent().add_child(bullet)
else:
var bullet_charged = load("res://Scenes/Bullets/bullet_charged.tscn")
var chargedBullet = bullet_charged.instantiate()
chargedBullet.position = get_global_position()
get_parent().add_child(chargedBullet)
func _physics_process(delta):
if Input.is_action_pressed("attack") && charge < 4:
charge = charge + 0.1
if Input.is_action_just_released("attack"):
shoot()
charge = 0