![]() |
Attention | Topic was automatically imported from the old Question2Answer platform. |
![]() |
Asked By | Sha6er |
am using this code to calculate a stamina system but i get problem
extends TextureProgress
func _ready():
max_value = Global.max_stamina
value = Global.stamina
$Label.text = "ST " + str(value) + " / " + str(max_value)
func _process(delta):
max_value = Global.max_stamina
if Input.is_action_just_pressed("attack"):
if value >= Global.damage * delta:
value -= Global.damage
$Label.text = "ST " + str(value) + " / " + str(max_value)
func _on_Timer_timeout():
if value < max_value:
value += 1
$Label.text = "ST " + str(value) + " / " + str(max_value)
the problem happens when the global variable is bigger than the textureProgress value
i can keep hitting attack and the value just keep reaching 0. i want it to stop the attack when the value is less than damage it should increases the value without the interruption of hitting attack action but what happen it keeps decreases the value even without the attack condition met.
Do you mean to have if value >= Global.damage * delta:
? It seems strange to check that conditional then immediately do: value -= Global.damage
.
if value >= Global.damage:
makes more logical sense to me.
timothybrentwood | 2021-06-24 15:02
am checking the damage value if it is less than the TextureProgress value it will substract the damage value from the TextureProgress value. forget about if value >= Global.damage * delta: it is not the main problem even if i change it it still won’t work properly as expected
what am having now when i attack it works good untill it reaches conditional bigger than TextureProgress value, then the TextureProgress value will increases but still i can’t execute attack animation although the conditional met.
anyway if anyone have another ideas to work it just share it i need the stamina system to work as described earlier.
Sha6er | 2021-06-27 15:34