Posted June 05, 2021 by amh271999
My game needed some stats that can help players keep track on their record. I created a player stats canvas before creating the script. I found the health icon from the UI folder and placed it on the top left corner. Then I made the bar by selecting background image found in the folder and empty images and set colours. Later I decided to add score and high score scripts, the score will count the current number of kills while the high score will save the highest score.
Originally I wanted a health counter out of 100 but later changed my mind due to the struggle of of adding the code. I later changed my mind which was to add a health bar instead. There were numerous tutorials on YouTube and decided to watch one of the videos to make my own health bar or slider. Once that was done I called the player stats script in the health script. I tested the game and the player stats was fully functional as the score updates after killing enemies, high score being saved and enemies decreasing player's health after being attacked.