Texture Progress not working

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

I want to have a Texture progress node displaying the amount of fuel my main character has remaining. This node displays a value from 0 to 100, so to get a percentage of fuel vs maximum fuel I used this code:

$CanvasLayer/TextureProgress.value = (fuel / MAX_FUEL) * 100

However, the progress bar simply appears completely empty. I tested it and it seems to work fine with any static value or single variable, which confuses me as this equation should be a plain integer from 0 to 100. Is there any solution for this, or am I just being dumb and doing something wrong? Thanks in advance!

Wich function you put this code?

EmanuelOzorio | 2020-05-04 18:12

:bust_in_silhouette: Reply From: kidscancode

This is the nature of integer division. 50 / 100 results in 0.

Change to float(fuel) / MAX_FUEL and you should be fine.