Hello!

I am using the timer to change the progress bar value inside the process function:
func _physics_process(_delta: float) → void:
progress_bar.value = timer.wait_time - timer.time_left

My question is, is there another way to do this? Because the timer only has the timeout signal.

Sorry, if this question is not a valid question, or it has been answered before.

  • xyz replied to this.

    xyz I really do not know. I am just wondering if there are other methods to do this, just to learn them or understand it, I am new to Godot.

    • xyz replied to this.

      RandomDice7 You can use a tween to directly animate the value property, avoiding the timer altogether.

        you could do it how ive been doing it, its not the most elegant way and personally I like yours better

        I set four variables 1 of which is just a reference to the progress bar
        @onready var progressBar: ProgressBar = $ProgressBar
        signal progress_completed
        var progressLength: float = 0.0
        var currentProgress: float = 0.0

        func _ready() -> void:
        progressBar.max_value = progressLength
        progressBar.value = 0.0

        func _process(delta : float) -> void:
        if currentProgress < progressLength:
        currentProgress += delta
        progressBar.value = currentProgress
        else:
        emit_signal("progress_completed")

        this is a much less elegant way to do what your doing but it does allow for custom signals also you could just use a timer timeout signal to trigger your custom signal to do what you want.

        hope this helps and isn't just garbage

        xyz I agree that tweens would be the best for something like that. Almost no need for addiotional custom code and you have much more control over value change. You can use different easing and if you need you can chain callbacks etc.