Stat Bars

Read Time:54 Second

HUD Bar Component

A HUD bar is composed of two equally sized images. The bar image is resized according to a percentage value passed to the Bar. The key to this is using the Size Delta property of the Image Rect Transform.


Ammo HUD Component

A Bar HUD can be added to any Canvas and linked up with any kind of stat that can be converted to a percentage. For instance, current and max ammo or health. Since these values are integers, one of them needs to be cast to a float or the division result will always be 0.


Health Component

The Health HUD is moved to the Health Bar component from the Target. References to the Health component, HUD Bar component and the Text component are linked up as appropriate.

Not a whole lot new going on in the Health HUD to accommodate the health bar, just a call to update the percentage.

The Billboard component is responsible for updating the Canvas so that it always looks at the Camera. Thanks to Brackeys for this one.

Happy
Happy
0 %
Sad
Sad
0 %
Excited
Excited
0 %
Sleppy
Sleppy
0 %
Angry
Angry
0 %
Surprise
Surprise
0 %

Average Rating

5 Star
0%
4 Star
0%
3 Star
0%
2 Star
0%
1 Star
0%

Leave a Reply

Your email address will not be published. Required fields are marked *