You are not in good health. Get a Health Bar Unity potion or gold coin to help you get better. Nearly every video game has an abstraction of health and a way to display it. Even those who are not very familiar with video games know what a “health bar” is. It’s the menu item at the top that displays how much health, mana, or other information you have.
Here are some best practices:
You can color code multiple health bars. Players will usually attribute green (or red), to their health, blue (or purple), to magic power, or yellow (or orange), to a timer. The colors should stand out from the chaos and background of the gameplay. This can be done by adding an outer layer to your health bar (which will be discussed later).
Limit your stat bar to within acceptable limits. After a devastating attack, no one wants to see their -250 HP.
Basic Static Status Health Bar Unity
- Create a new Canvas in the scene. Right-click the Canvas. This image should be called “HealthBar”. This will be the “shell”, for the health bar.
- The image can be resized to look like a “health bar” (rectangular, anchored at the top left of your screen). Change the color of the image to black
- Let’s now move on to the real health bar. Click on HealthBar and then repeat the process. This image should be named “HealthBarInner”. Change the color of the image to green
- Adjust the image to stretch horizontally and vertically. Then, manually resize the image so that it is slightly smaller than the outer black rectangle. Drag the image so that it is in the center of the oter black rectangle. Refer to the image below for an example.
- Select “Filled” for the Image Type HealthBarInner. Next, change the Fill Method to Horizontal and Fill Origin to Left. Now you can play with the health bar by moving the Fill Amount bar left or right. Huzzah!
Unity Per Entity – Dynamic Status Health Bar
Although the above example of a health bar implementation is admirable, I believe we can do more. Here are some improvements that we plan to make to this health bar.When player health changes, animation of the health bar Change the color.
Health Bar Unity conditionally based upon color left
Set up the health bar so that it floats above the player and the billboard in one direction.Set the health bar so that you can fade out when your body is moving and stay still when you are stationary.Although it may seem like a lot of work at first, intermediate Unity developers will be familiar with the tools available.