The main difference between a Player's Health Bar in the HUD vs an Enemy's is creating the Health Bar in WORLD SPACE.
In stead of overlaying UI on the Camera, the Enemy or Game Object itself has a Canvas attached to it as a child object, and the UI is a part of the Enemy GameObject.
The benefit of this is the Health Bar follows the Enemy around, the downside is we need to make sure it stays oriented and positioned properly as it does.
Learn all about how to solve for that easily here without needing a single asset of your own.
Using Unity's Slider UI component out of the box we can use the guts of that to make a working health bar in close to 5 lines of code.
Смотрите видео Easy Enemy Health Bars in Unity онлайн, длительностью часов минут секунд в хорошем качестве, которое загружено на канал BMo 02 Май 2023. Делитесь ссылкой на видео в социальных сетях, чтобы ваши подписчики и друзья так же посмотрели это видео. Данный видеоклип посмотрели 53,252 раз и оно понравилось 1.1 тысяч посетителям.