TextureProgressBar not updating

Godot Version

`4.4

Question

`Hi ,
I have this code


which basically just calls these functions in a Global Scene.

But if they are called with some values the texture in the progress bar isn’t updated but the value and max_value is updated in the editor

Hi!

If you set both max_value and value of the progress bar to the same value (here, maximum_munition), it’s normal that the progress bar is full.

Progress bar works by a percentage: you take the value, and you divide it by max_value to get the progress percentage. For instance, say you have 10 max munitions, and 6 currently owned, then that would give 6/10 = 0.6 (which, multipled by 100, gives 60%).
By setting the same value, the percentage will be 100% (as any value divided by itself gives 1, which is equivalent to 100% in that context).

Try to set the progress bar value to the number of munitions left, instead of maximum. You should be able to simply remove the second line in update_max_munition_bar.

Hi!
Thanks for noticing my problem.
The thing is that the progressbar is even after configuring the value still the same.

Could you show your updated code?

nothing has changed

Are the update_munition and update_max_munition_bar functions called somewhere else that in _ready()?

No, just in the one ready function above .

Okay, could you add some prints on stats values and share them here?
Like, in ready, before refreshing your progress bars, do:

print(stats.munition)
print(stats.maximum_munition)