how to create a countdown timer that uses the progress bar as the timer?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Regret

i would like to create a countdown timer that uses the progress bar as timer?

:bust_in_silhouette: Reply From: johnygames

Create a new scene. Add two nodes, a ProgressBar and a Timer. Create a new script for the root node of the scene. Write the following code in it:

extends Node2D
onready var timer = get_node("Timer")
onready var pb = get_node("ProgressBar")

func _ready():
	timer.wait_time = pb.value

func _process(delta):
	#print(timer.time_left)
	pb.value = timer.time_left

Now your Timer uses the ProgressBar’s value as its countdown time. You can even see the ProgressBar decreasing as time goes by.

In case you didn’t know, you can set the ProgressBar’s value by using its value method.
If this is what you want, please mark this answer as best.