top of page

Day 30: Player health and damage

Updated: Aug 6, 2023

My plan for the day: Creating a health bar using unity UI was easy enough, but it was getting the healthbar to reduce in size when damage is taken that was the challenging bit. What I accomplished: I started off by using the Unity UI canvas feature to create a rectangular bar that sat at the bottom right of the screen, and was red in color. Once the easy part was out of the way, it was time to start coding in the script to make the health bar dynamic. I added in lots of serialiazed fields which would account for player stats, otherwise known as the player's attributes. For example, how much health, stamina and strength he had. Once those were done, I used lerping to create a smooth commonly used effect of health reduction in lots of modern games that flashed yellow when taking damage. Once those were done, I started adding in some animations. For now, I only needed two: the taking damage and death animation. I quickly added some in from mixamo, and joined them using transitions to the base blend tree. Now, everytime the healthbar reduced in size, the damage taken animation would play, and if the healthbar went completely down to zero, then the death animation would play.


_______________________________________________________________________________________________________



Comments

Rated 0 out of 5 stars.
No ratings yet

Add a rating
bottom of page