Making a health bar dynamic
I have a timer set to degenerate the health bar by set amount per second.
I'd like to make a key press stop the degeneration for 3 seconds, and to not have this conflict with other key presses with add health to the bar.
Thank you
I'd like to make a key press stop the degeneration for 3 seconds, and to not have this conflict with other key presses with add health to the bar.
Thank you
Comments
every 1 second
change att currentHealth = currentHealth - 1
if key "1" is pressed
change lifedegenerateON = false
if lifedegenerateON = false
after 3 seconds
change lifedegenerateON = true
this would not affect other changes to currentHealth att
I'm assuming the "Lifedegenerate" is a game attribute that I should create? And if so, what type (integer, boolean, etc.). The reason I ask is because I tried naming the specific rule that does the health degeneration to "lifedegenerate" and trying use another rule to manipulate it, but it would show nothing when I typed it in.
Just set the boolean to true (checked) when you create it. The rule above will start decreasing health each second as long as game.lifedegenerate is true.
every 1 second
change att currentHealth = currentHealth - random(1,10)