top of page
  • Writer's pictureJoshua Keene

Final Major Project - Health & Stamina

Updated: Apr 29, 2021

The next logical step in production was programming the health and stamina systems, while it may seem mundane there are several interesting design challenges to think about. What actions will cost stamina? Will the player regenerate health and stamina in combat? Will there be a delay before regeneration kicks in? etc.

With all of these variables in mind I decided to make my stamina system as customisable as possible. Making use of Unity's state machine behaviour scripts I created a script that I could place on the appropriate states in the player animation controller. I then use the drop down to tell the script what action it is on (It uses this to get the appropriate stamina cost from the health & stamina script that sits on the player). Using the tick boxes, I can then easily customise if I want an action to stop stamina regen while it is taking place, whether I want there to be a delay after the action stops before regeneration continues and finally whether I want the stamina cost to be drained continuously while the action is occurring. This high level of quick and easy customisability allows me to make rapid changes at any point during future testing and iteration.

Something I didn't consider during planning, but I realised during production was that it didn't look very polished to have the stamina jump down in an instant, in most games the bar smoothly slides from its original value to the new one. I decided I also wanted to do this to achieve a more high-quality looking system. I researched and found a method on a Unity forum by a user called kru that used Unity coroutines, I took this method and adapted it to fit my system and achieved the desired effect.

The player health also make use of this coroutine and other logic used for stamina like the code used to give and take stamina, though it does not require the same customisability.

14 views0 comments

Recent Posts

See All


bottom of page