TextureProgressBar not rendering value change

Godot Version

4.2.1

Question

My health and stamina bars are not visually changing when the value is updated.

“test” is bound to the ‘X’ button
min_value and max_value were left on the default values of 0 and 100
value was set in the editor to be 100

signal stamina_changed(old_value, new_value)

func _physics_process(delta):
	if Input.is_action_just_pressed("test"):
			change_stamina(-10);

func change_stamina(amount):
	stamina_changed.emit(stamina, stamina+amount)
	stamina += amount

Then, in the script on the stamina bar

func _on_player_stamina_changed(old_value, new_value):
	value = new_value
	print(str(old_value) + " " + str(new_value))

The print puts the correct old and new values in the console, but the textures on the progress bar don’t update. They do visually change if I change the value in the editor

I cannot reproduce this. Can you share an example project with the issue?

2 Likes

I figured out the issue. It wasn’t code related.

There were 2 issues:

  1. I had the fill mode set as left to right on a vertical meter that was 2 pixels wide, so there wasn’t any visible difference.
  2. Even if I the fill mode was set properly, I realized I had 2 UI’s, one attached to the player scene and one in the world scene. So I was seeing a UI that wasn’t updating.

@njamster Creating a test project for this let me find these issues, so thanks for the help