Godot Version
4
Question
Hello, I’m practicing a little in Godot and I want to make a stamina bar. The thing is, when the stamina reaches 0, I want to forbid the player from sprinting until it refills to a certain point (say, 20. The range goes from 0 to 100). This is the code I have now in the _physics_process(delta)
if Input.is_action_pressed("ui_sprint"):
if stamina >= 0:
speed = 100
stamina -= 2
stamina_updated.emit(stamina, max_stamina)
elif Input.is_action_just_released("ui_sprint"):
speed = 50
And in _process(delta)
var updated_stamina = min(stamina + regen_stamina * delta, max_stamina)
if updated_stamina != stamina:
stamina = updated_stamina
stamina_updated.emit(stamina, max_stamina)
What should I do to achieve what I want? If you know of any resources to learn from I would appreciate it. Thank you very much!