Reducing an integer by X per second

I am trying to make a simple stamina bar. So when you are holding left shift to sprint the stamina which has a start value of 100 is decreasing by 5 per second.

if(Input.GetKeyDown(“left shift”))


Running = true;

staticVAR.STAMINA -= 10;


As you can see here it is currently just reducing the value by 10 each time the key is pressed, but I would like it to decrease as the key is held down. Can anyone help me out with this? :slight_smile:

To make any rate “per second”, multiply by Time.deltaTime:

staticVAR.STAMINA -= 5f * Time.deltaTime;