Im new to godot and I am working on a leveling up system. I want to add a tween to the progress bar so it moves smoothly whenever you gain exp. But whenever I add exp the tween only goes ~3/4 of the way is is meant to go. Like I said I am new to godot so it may be simple.
(I apologize if it is not in code formatting I looked around for a while but could not find anything on how to do it)
Here is the piece my code not working:
i would like to know the specifics of your bar and the values.
What is the bar’s max_value and what value is given to exp?
You said it only fills up 3/4 of the way, so could you check if the values are the same or if there is a weird max_value or step property configured.
The first max_value is 100 then it gets multiplied by 1.15 each level. EXP starts at zero but if you press a button it goes up by 5. I have tested the progress bar without the tween and it displays the correct value so I assume it is a problem with the tween I made.
Here is all of my code in case you need anything else:
extends Control
@onready var text = $LevelText @onready var bar = $LevelBar @onready var counter = $expCounter
var level = 0
var exp = 0
var exp_for_level_up = 100
func _ready() → void: #PLANNING TO ADD A SAVE/LOAD FEATURE #SETS VARIABLES TO SAVED DATA
bar.value = exp
bar.max_value = exp_for_level_up
func _process(delta: float) → void: #HANDLES LEVELING UP AND VISUAL REPRESENTATION OF EXP
if exp > exp_for_level_up or exp == exp_for_level_up:
#IF THE exp IS GREATER OR EQUAL TOO exp_for_level_up FOR LEVELING UP IT RESETS THE EXP AND GAINS A LEVEL
exp = 0
exp_for_level_up = round(exp_for_level_up * 1.15)
bar.max_value = exp_for_level_up
print(exp_for_level_up)
level += 1
text.text = "[center]Level: [/center]" + str(level)
print(level)
else:
#SETS THE BAR AND exp COUNTER
var tween = get_tree().create_tween()
tween.tween_property(bar, "value", exp, 1)
#bar.value = exp
counter.text = str(exp) + "/" + str(exp_for_level_up)