0 votes

I have a progress bar and use a export var "progress" as the progress value and want it to decrease with as the timer decrease. But its not working. Here is my code:

axeprogress.visible = true
var t = Timer.new()
t.set
waittime(4)
t.set
oneshot(true)
self.add
child(t)
t.start()
axeprogress.progress = t.timeleft
yield(t, "timeout")
axe_progress.visible = false

asked Jun 4 in Projects by jm4rcos (20 points)

1 Answer

0 votes

Hi,

I don't know where you are running this code or how you are calling it, but I think the issue could be that you are creating multiple timers, maybe.

Anyway, this code worked for me. I added a bool for timer_required so the timer was only started once. I get a countdown. Not sure it's exactly what you want though.

if timer_required:
    t = Timer.new()
    t.set_wait_time(10)
    t.set_one_shot(true)
    self.add_child(t)
    t.start()
    timer_required = false
axe_progress.value = t.time_left
yield(t, "timeout")
axe_progress.visible = false
answered Jun 4 by deaton64 (1,261 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.