Easy Enemy Health Bars in Unity

  Рет қаралды 59,699

BMo

BMo

Күн бұрын

Пікірлер: 60
@tgporter07
@tgporter07 Жыл бұрын
For anybody who ran into problems with the health bar stretching when rotation is added, I was able to fix this by changing the rotation of the canvas rather than the health bar UI item itself. This is a simple fix: transform.rotation = camera.transform.rotation; becomes transform.parent.rotation = camera.transform.rotation; hope this helps some people out!
@animezeingamer
@animezeingamer Жыл бұрын
Thank you. Went looking for this comment when I ran into the issue myself. 👍
@DPTecas
@DPTecas Жыл бұрын
You are the man, thank you
@MrWebbtang
@MrWebbtang Жыл бұрын
You are a legend, I was tearing my hair out trying to fix this. Can't believe I fell into the 'rotating a scaled transform' trap AGAIN
@TransGuyShane
@TransGuyShane Жыл бұрын
I literally never thought of adding health bars directly to enemies, with its own canvas and everything 😅 Thanks for the tutorial ♡
@_Garm_
@_Garm_ Жыл бұрын
welcome back, was just wondering where you dissapared :)
@bigp0y
@bigp0y Жыл бұрын
It's been too long, bmo. We demand more videos!
@kimolsson8564
@kimolsson8564 Жыл бұрын
The King strikes again!
@eileeng2492
@eileeng2492 Жыл бұрын
Hey so glad youre back. Love your videos
@theanimationstation9644
@theanimationstation9644 Жыл бұрын
That was short, informative , well explained….. I loved it
@SneezeAlpha
@SneezeAlpha Жыл бұрын
You are back!
@mandamoon9149
@mandamoon9149 Жыл бұрын
Clicked on this so fast 💨 Bmo is the tutorial rizzler
@rgodoy86
@rgodoy86 Жыл бұрын
Amazing tutorial. There are so many overcomplicated videos on KZbin. You did it simple and straight to the point. Thanks!
@MajesticMindGames
@MajesticMindGames Жыл бұрын
Nice, thank you for making this.
@globes179
@globes179 Жыл бұрын
Great - very good teacher
@pixelsoupgames
@pixelsoupgames Жыл бұрын
I'll keep that saved. Thanks!
@linsfunbox4052
@linsfunbox4052 7 ай бұрын
Very good tutorial. However, I can see the border of Canvas in game view. Not sure why. How to get rid of border of Canvas in game view?
@Stompin40
@Stompin40 Жыл бұрын
This is so damn helpful!!!! Thank you, thank you, thank you!!!!!!
@yuxuan130411
@yuxuan130411 Жыл бұрын
does it ever go to zero? looks like there is always a little bit color left
@evilMissRune
@evilMissRune Жыл бұрын
a helpful and simple video, and exactly what i was looking for. thank you
@pixelart0124
@pixelart0124 11 ай бұрын
Very helpful and simple and easy, thank you so much!
@BMoDev
@BMoDev 11 ай бұрын
Appreciate it, now go make the best game of all time
@ProfesserSeal
@ProfesserSeal 29 күн бұрын
I have the health bar working, but how do I make it so that the health bar stays at the top of my game scene and not move with the enemy character?
@wob3786
@wob3786 28 күн бұрын
Works for me but leaves an annoying white square artifact i cant seem to remove
@iiropeltonen
@iiropeltonen Жыл бұрын
Wow! You're Back! Welcome I missed your coding videos!😢❤
@lymincs8031
@lymincs8031 Жыл бұрын
First, reference the Sprite Renderer next to the variables with "public SpriteRenderer sprite" Then, use code to change the color when the health is under a certain amount. For example, if you wanted it to turn red when under 50 health, you could write "if(health < 50) { sprite.color = red; } Hope this helped! (Also I've never actually tried it, but if I had to guess, this is how you would do it.)
@shonsomech7839
@shonsomech7839 Жыл бұрын
do you have tutorial for that shooting? it looks really good and the way it bounces :D
@Tbout72
@Tbout72 8 ай бұрын
Why in the Canvas in the Event Camera you didn't assign the Main Camera ?
@mocheford
@mocheford 9 ай бұрын
Hey that's a great tutorial, I will use it. A question : My enemies come from far away, how do I keep the health bar big enough to always see it ? Will it shrink as if with the distance ?
@AnbuBlackFro
@AnbuBlackFro Жыл бұрын
Getting an issue on the floating health bar script. On public void update health bar "must declare a body because it is not marked abstract, extern or partial" and on the line below at 5:04 slider, current and max value "does not exist in current context" anyone know where i went wrong 🙏🏾
@Ryöken17
@Ryöken17 5 ай бұрын
looking for you healthbar in children takes too long for the game, you could do it like your slider, drag and drop?
@TibiaOTarena
@TibiaOTarena 9 ай бұрын
so what if there a multiple enemies? I use pooling for them do I hvae to pool the canvas separately?
@danielinverso5869
@danielinverso5869 Жыл бұрын
Also if for some reason you don't want to have a camera variable, Quaternion.identity also works fine though my project is 2D so I dont know if it works in 3D or not.
@Smudge04
@Smudge04 Жыл бұрын
when it got to the rotation part, when i locked the slider in place, it just started stretching, do you know a fix for this? loved the video!
@n0teEditsss
@n0teEditsss 7 ай бұрын
My health bar starts at 0 and then when i shoot it, it goes to 10?
@Cgtchilly
@Cgtchilly Жыл бұрын
how do i make it fetch the cameras position on its own and not have to drag it in so when i make a enemy preset i dont have to drag it in to everyone i place down
@MohamadNurjaman
@MohamadNurjaman Жыл бұрын
i did it till the increase and decrease teh value, but when i play it, and add background sprite like Mountain or something, the hpbar was covered by the background sprite, how to fix it ? i already tried to put sprite renderer on the canvas but not work
@botcomborderreaching3518
@botcomborderreaching3518 9 ай бұрын
Same problem, I have health bar on asteroid, but asteroid keeps blocking it
@YusafAnimations
@YusafAnimations Жыл бұрын
how to make it turn yellow and red at certain health?
@chinesepetants2767
@chinesepetants2767 Жыл бұрын
One question, if I make too many monsters by prefab in one scene, does that mean it will create tons of canvas? Is that ok?
@namk0163
@namk0163 8 ай бұрын
Does anyone know why he uses [SerializeField] instead of the regular private access modifiers?
@BMoDev
@BMoDev 8 ай бұрын
Shows up in unity inspector
@guillermozafra8993
@guillermozafra8993 8 ай бұрын
This tutorial rotates the whole object to rotate the canvas alongside it. In 3D, your whole model will be facing the floor when rotated, instead of just the model. Doing slider.transform.rotation instead of transform.rotation is an easy fix
@benriffe4705
@benriffe4705 Жыл бұрын
great video thanks bud!!
@Ryöken17
@Ryöken17 5 ай бұрын
We have to rotate the health bar cause you made the enemy rotate, so why rotating him ?
@FRANCOPROHOLA
@FRANCOPROHOLA Жыл бұрын
Nice video man :D
@mindbodymusic21
@mindbodymusic21 Жыл бұрын
Hi great video loved it small suggestion link in the description or end of video related videos
@Meireiyangpanmei-g8f
@Meireiyangpanmei-g8f 4 ай бұрын
Thank you sir
@vovanphat8040
@vovanphat8040 Жыл бұрын
very very helpfull thanks you.
@GTN2852
@GTN2852 10 ай бұрын
My game Helth bar app avalable
@katkatgame
@katkatgame 5 ай бұрын
Thank you
@marcosrodriguez1590
@marcosrodriguez1590 Жыл бұрын
Thank you!!!
@johnnygamer4933
@johnnygamer4933 2 ай бұрын
You made the Slider slider private, and the you instantiate from unity... that's cheating.
@tapcoin5513
@tapcoin5513 9 ай бұрын
thanks
@superadi2774
@superadi2774 Жыл бұрын
thanks a lot
@Johnnys_Manager
@Johnnys_Manager 25 күн бұрын
was hard asf ngl omg
@Johnnys_Manager
@Johnnys_Manager 25 күн бұрын
did it tho💔
@zote1
@zote1 4 ай бұрын
here is the code if anyone wants it remamber change the name the one you are using using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; public class FloatingHealthBar : MonoBehaviour { [SerializeField] private Slider slider; [SerializeField] private Camera camera; [SerializeField] private Transform target; [SerializeField] private Vector3 offset; public void UpdateHealthBar(float currentValue, float maxValue) { slider.value = currentValue / maxValue; } void Update() { transform.rotation = camera.transform.rotation; transform.position = target.position + offset; } }
@zaidalfayyadh_2537
@zaidalfayyadh_2537 Жыл бұрын
Great tutorial!! subscribe.
@sourirerouge9995
@sourirerouge9995 3 ай бұрын
ty ty
CUTSCENES in Unity using Timeline
13:24
BMo
Рет қаралды 73 М.
Unity Player Health and Health bar Tutorial
10:52
MoreBBlakeyyy
Рет қаралды 22 М.
Вопрос Ребром - Джиган
43:52
Gazgolder
Рет қаралды 3,8 МЛН
How to make a HEALTH BAR in Unity!
21:06
Brackeys
Рет қаралды 1,2 МЛН
I Made A Platformer Game But You're The Enemy
6:12
BMo
Рет қаралды 652 М.
I Made the Same Game in 8 Engines
12:34
Emeral
Рет қаралды 4,3 МЛН
How Do Game Devs NOT Overscope??
9:04
Green Light Dev
Рет қаралды 10 М.
How To DAMAGE Enemies in Unity
9:19
BMo
Рет қаралды 45 М.
World Space Health Bars That Follow Units | Unity Tutorial
13:28
LlamAcademy
Рет қаралды 22 М.
Flexible LOOT SYSTEM in Unity with Random Drop Rates
13:24
A new way to generate worlds (stitched WFC)
10:51
Watt
Рет қаралды 548 М.
I made a full GAME in 400 HOURS - this is how - in 19 minutes!
19:00