Hi, I have made a simple sprint system but I have a problem with the energy replenish and deplate time.
gv.energy_deplation_rate and gv.energy_replenish_rate are both set to 100
I made a progress bar for it and its default and max. value is 1000. In the code it should deplate the energy in 10 seconds and replenish it also in 10 seconds.
Problem is that it will deplate in around 9 seconds and replenish in about 16 seconds...
Here is the code:
# Add the gravity.
if not is_on_floor():
velocity += get_gravity() * delta
var direction := Input.get_axis("move_left", "move_right")
var is_sprinting = false
# --- SPRINT ---
var sprint_multiplier = 1
if Input.is_action_pressed("sprint") and gv.energy > 0 and direction != 0:
is_sprinting = true
gv.energy -= gv.energy_deplation_rate * delta
sprint_multiplier = gv.sprint_bonus
else:
sprint_multiplier = 1
is_sprinting = false
if not is_sprinting and gv.energy < 1000 and is_on_floor():
gv.energy += gv.energy_replenish_rate * delta```