+1 vote

Hi everyone!
I have a texture progress node and now I am trying to update its bar as below

$TextureProgress.value = Globals.coins
$TextureProgress.max_value = Globals.coins_max

I also have a Autoloaded script (i.e. Globals) with these variables

var coins : int = 500
var coins_max : int = 500

So it should show the full bar but its showing a very small portion of the total length of bar. I don't find any mistake but still the bar is not showing the correct length.
Thank you!

in Engine by (909 points)

1 Answer

+1 vote
Best answer

Heya!

So... this will sound pretty silly, but I think the solution is to simply swap these lines:

$TextureProgress.max_value = Globals.coins_max
$TextureProgress.value = Globals.coins

What's happening (I think) is that because you set your value before you set your new max value, it instead gets set to the previous max (e.g., 100).

Thus when you set your new max, what's displayed is only a fraction of the total.

Hope it helps!

by (1,000 points)
selected by
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.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.