DevLog5: UI Elements


For this section I implemented basic UI elements for the level such as health/ammo bars/sliders, buttons, and title texts.  In order to do this I linked some of these elements, placed and fixed in the canvas, with the player health and shooting scripts so changes in both floating point variables can be recorded when receiving damage or collecting a health token (single increment or decrease, i++ or i--).  In order to limit the maximum amount of life points or ammo that could be collected  (despite slider being set to a maximum, it wouldn't visibly decrease until the associated variable was reduced to a lower value),  I used constant variables named as maximumHealth or maximumAmmo that were used inside if statements in an update function so once the ammo or health variables recorded higher values, these immediately adopt the value of the maximum variable. An additional feature involving UI elements consisted in triggering a GameOver screen, that was set as disabled from start, once the health slider reached to 0 or a Deathzone collider in a pit detected a collision with the player object.  This screen uses a black background image with an alpha value set at approximately 0.5 so obstructs the view from the game scene and presents texts and buttons with options to restart the game or return to menu. Finally, so far I have implemented 3 different scenes that are the title screen, the Level 1 scene, and the settings one. From the main menu the user can either go straight to play the Level 1 Scene or go to settings on which using the Player Preferences class, player prefs, the user can store information on the Audio mixer component to set the desired volume for his/her play run.

References:

SpeedTutor (2021, June 1).  Unity Audio: How To Make a UI Volume Slider (Saving & Loading). [Video]. YouTube. 

https://www.youtube.com/watch?v=k2vOeTK0z2g

Files

RuneCaster_PlayTest_v2.zip Play in browser
Oct 05, 2023

Get Codename: Rune Caster

Leave a comment

Log in with itch.io to leave a comment.