How do I create a Stamina Gauge/Attack Timer?

I was wondering if I could get any help and advice regarding creating a stamina gauge in C#.

I want to create a (full) stamina gauge and when the player uses a attack, it deplets it temporarily until the timer has deceased and the player can use the attack function again. This would be for a UNITY 2D Side-Scroller. :slight_smile:

This way in my game, players would know how often they can attack with this. Any help and advice would be much appreciated.

Fastest way is to scale a set of 3 colored Quads. Rear is Red, Mid is Blue, Front is Green control their scale via C# script. Donโ€™t forget to put your colors in an atlas rather than separate materials and save yourself a few draw calls.

When you are feeling more advanced, Iโ€™ve had a ton of fun working with Alpha Clip shaders, but it can be a pain to set up.