Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | Leander |
I’m having issues with a timer not counting down when running my project. Here is the code, perhaps I’m doing something obviously wrong but I can’t see it
Player.gd
var weapon_scene = preload("res://scenes/Weapon.tscn")
var weapon = weapon_scene.instance()
func _process(delta):
if Input.is_action_pressed("fire"):
weapon.fire()
Weapon.gd
(Weapon.tscn has a timer named CooldownTimer with one-shot set to true and wait time 1 second)
func fire():
if $CooldownTimer.is_stopped():
$CooldownTimer.start()
print('Firing!')
else:
print("cooldown...", $CooldownTimer.get_time_left())`
Seems pretty straightforward, but the first time I press the key says “Firing!” and every time after I get “cooldown…1”
I also added a callback on the timer’s cooldown and it never gets fired.
Thanks in advance if you can tell me whats wrong