Oskar Karlsson Game dev – Health Bar code
|
I am Oskar Karlsson the lead programmer for the Archon group and we are working on the game Aetherial. For this week I have worked on the GUI code. The GUI includes health bar and a Aether bar. And during this sprint our groups prime goal was to get the beta requirements done and a simple GUI was one thing that was needed. The GUI code for the health of the player is needed in this game because the Concept document have it in it. Also, the Aether bar is needed for the Aether power that will make the player teleport and then it will reduce the meters value. And the player needed to be able to die and that’s why the health bar is needed. We in the group decided that this GUI was needed because it was the easiest way to show the player its health and Aether and it was the easiest to make in unity. The colors of the bars were green for health and blue for the Aether pickup because the Aether pickup that is spawned by the enemy is blue. I started off by searching on google for health bar code in Unity. After a while I found a good tutorial on YouTube where they go through how to code a good health bar GUI and on how to use it on the player. 2 new C# codes needed to be created and they were called Bar Script and Stat. The Bar script takes care of the calculations for the bars, how much they can fill and how fast they can fill. The Stat code takes care of the current value of the bar and then sends it to the player. the player also needed some code were the health bar is connected to how much damage the player takes. And the Aether bar is connected to the teleportation of the player so the bar decreases when it is used. The bars were created by one of the artists in the group and I implemented them to unity. In unity I needed to make a canvas for the GUI to work and in it I made a new image. I also created an image on that canvas and named it health bar. And on that image, I made two new images that I named mask and content and they are children of each other. The bar script was put on the HealtBar image. To the mask image I added a mask script. When the health bar was finished I duplicated it and made the Aether bar the exact same way as the health bar. I think it turned out ok because it works as intended and the values can easily be changed. After it have been tested it could be marked as finished in the sprint planning and it was before the Alfa test. |
