World Space Health Bars That Follow Units | Unity Tutorial

  Рет қаралды 22,408

LlamAcademy

LlamAcademy

Күн бұрын

Пікірлер: 51
@xAjido
@xAjido Жыл бұрын
Small thing that doesn't really matter but the OnTakeDamage is only killing the unit if the health is less than 0, instead of less than or equal to 0. Thanks for the video!
@LlamAcademy
@LlamAcademy Жыл бұрын
Oops! Great callout. Thank you!
@back2back712
@back2back712 2 жыл бұрын
Here to help you!! Yes, You!! (Loved it)
@durvids474
@durvids474 2 жыл бұрын
Great video as always! Keep em coming!!
@LlamAcademy
@LlamAcademy 2 жыл бұрын
You know it! 😉
@bluzenkk
@bluzenkk Жыл бұрын
I'm so glad that I purchased the asset Shape to do this world space health bar thingy...
@AlejandroGonzalezGM
@AlejandroGonzalezGM 8 ай бұрын
Would this method be efficient in an RTS with hundreds of units? I've read some concerns about using Unity UI system, and I'm wondering whether that has to do with using several canvases (one for each health bar) and if using just one world space canvas woud also be problematic.
@LlamAcademy
@LlamAcademy 8 ай бұрын
When I made this it was definitely more performant than running single item canvases per unit. Depending on the scale of RTS this could be fine. If you have thousands of units you probably need some ECS system instead
@TheJungaBoon
@TheJungaBoon 2 жыл бұрын
Excellent video as usual!
@LlamAcademy
@LlamAcademy 2 жыл бұрын
🙌thank you!
@sunnykwan5630
@sunnykwan5630 Жыл бұрын
10:58 the health bar frame is slightly "broken" (instead of having a round rectangle, it become scratchy) in some of the angle, and it doesn't look good. I think it is because the Face Camera script doesnt make the bar rotate perfectly to the screen. What are the possible solutions for that?
@sunnykwan5630
@sunnykwan5630 Жыл бұрын
its solved by rotating the canvas instead of the health bar itself
@LlamAcademy
@LlamAcademy Жыл бұрын
great to hear!
@wulfB
@wulfB Жыл бұрын
Which part of the script makes a health bar follow its respective unit? Since the UI object is being parented to the canvas I imagined you'd need an update method somewhere in the unit or health bar, to keep them both on track.
@LlamAcademy
@LlamAcademy Жыл бұрын
You are correct, there is a script on the HealthBar called FollowTarget that, on Update, sets the position to the Target's position + the Offset (see around 9:35)
@wulfB
@wulfB Жыл бұрын
@@LlamAcademy Ah ok thank you! And thanks a lot for these videos, they've been incredibly helpful, especially the ones on navmesh!
@aabb-em6bc
@aabb-em6bc 2 жыл бұрын
Health bar, quest mark on the head of the NPC, etc I wonder which method is best for these general requirements. This will also be possible with a single screen space overlay canvas. Or Health bar prefab may be owned by all objects as world space canvas. (with multiple world space canvas) Is there any special reason to use the method introduced in this KZbin video? Which method is the most common?
@LlamAcademy
@LlamAcademy 2 жыл бұрын
Sorry I don't understand the question. Is the question: is it better to use a single screen space overlay canvas or multiple world space canvases? I would recommend a single World Space, that's what we did in this video. I'm sure other ones would work, but Unity recommends against having a ton of canvases with single elements because each Canvas has some overhead.
@alperaydin7011
@alperaydin7011 2 жыл бұрын
Very Nice , Thanks
@RogerHNobrega
@RogerHNobrega 2 жыл бұрын
The progress bar video isn't available anymore? The link in description doesn't work for me.
@LlamAcademy
@LlamAcademy 2 жыл бұрын
Weird.. thanks for letting me know! Try this one. I will edit the description as well kzbin.info/www/bejne/h6iboJeCfdtmbrM
@saadblabla
@saadblabla 2 жыл бұрын
Hey its me again! I just played cod mobile and , not only sound, but also bullet impacts are applied based on texture. How do they do that? Can you do a tutorial on it ?
@LlamAcademy
@LlamAcademy 2 жыл бұрын
Hi again! :) I have one that shows how to play a bullet impact based on a Material: kzbin.info/www/bejne/aJOzlZKaotZ6q68 You can use that and mix it with the what you learn in the terrain audio sound playing one (kzbin.info/www/bejne/j4mbdmR3eph1j9U) if you want it to be texture based!
@4ndr3w1431
@4ndr3w1431 Жыл бұрын
You spoke too quickly about the single canvas bit... how are the healthbars rendering on a single canvas but all facing different directions?
@LlamAcademy
@LlamAcademy Жыл бұрын
Each health bar is its own Transform, so we can independently rotate those to look at the camera, just like any other Transform component. There's nothing restricting a UI element to be aligned to be perfectly flat on the Canvas!
@Jumph96
@Jumph96 Жыл бұрын
Hey, just wanted to preface this by saying that the content you're creating is invaluable, helped me quite a lot. I've tried implementing what you've shown in the video, my only difference is that there's a moving Third person camera attached to my player that moves around the playarea. I noticed however that whenever I move the camera around the sizes of the healthbars change. I think it's tied to the angle at which I'm looking at them from. But I thought that the billboarding script was supposed to address that? I mean, the healthBars do face the camera, but the size keep changing. I don't understand why that is.. ? Cause technically they should always point to my camera and so never change size... Maybe?.. 🤔
@LlamAcademy
@LlamAcademy Жыл бұрын
Hey! Sorry for the delay on getting to this one. Because we're using "world space" health bars, the size of each health bar will be scaled as it gets farther away from the Camera. Just having them face the camera makes it so they are always aligned to be "looking at" the camera so you can always see the full health bar. For non-size changing health bars I think you need to use a ScreenSpace camera and find the position of the object on the canvas and position the object based on that. I think docs.unity3d.com/ScriptReference/Camera.WorldToScreenPoint.html WorldToScreenPoint helps here
@Jumph96
@Jumph96 Жыл бұрын
​@@LlamAcademy ​Thanks for the reply I'll look up the Unity API link you sent 👍. Don't know if you saw one of my older replies under one of your videos, but in any case, I just remember mentioning an idea for a possible new video, something like a Quest System would be great (Having it based on NPC Interactions or with quests assigned sequentially by a QuestManager in the scene).
@stalkerkk
@stalkerkk 2 жыл бұрын
Kindly one tutorial on Full body fps ik.
@LlamAcademy
@LlamAcademy 2 жыл бұрын
A challenge! I’ll add it to the topic list!
@Wannenbichler
@Wannenbichler 2 жыл бұрын
Just wanted to say i really love your content. In the project i'm currently working on i also have similar health bars that are implemented differently, but have the same problem i see here: sometimes the bars from agents that are further away from the camera get drawn on top of others that are closer. This obviously is caused by the child order of the canvas, that ofc does not correlate to the camera distance. I haven't found a solution to this yet...
@LlamAcademy
@LlamAcademy 2 жыл бұрын
Thanks I appreciate that! For that problem you can try something like a "Heath Bar Manager" script that manages the sizes and the health bars and the order of the heathbars. For example maybe farther away ones you may want to scale down and closer ones scale up to the size we have in this video. You can keep track of each health bar as they're added to the Health Bar Canvas in a similar way to how we SetUpHealthBar on the Enemy. Then you can check with the Vector3.Distance between each enemy and the camera and order them on the Canvas by that distance.
@Wannenbichler
@Wannenbichler 2 жыл бұрын
@@LlamAcademy Thanks for the reply! I am mostly concerned with the ordering, and i just found the methods SetAsFirstSibling,SetAsLastSibling and SetSiblingIndex in the docs. I guess these are what i was looking for, and i can use them for ordering by distance as you said.
@LlamAcademy
@LlamAcademy 2 жыл бұрын
@@Wannenbichler awesome!
@obscureskeleton
@obscureskeleton Жыл бұрын
Just a heads up for anyone experiencing this issue in the future, adding a small plane behind the health bar (depending on the bar's shape) also works. Make sure it's a child of the health bar and only just slightly behind it, and the player shouldn't be able to see it as they rotate around it. You can also make it the colour of whatever your health bar backing is and replace that with it.
@sim-card8685
@sim-card8685 2 жыл бұрын
My question is where do we initialize our ProgressBar Healthbar?
@LlamAcademy
@LlamAcademy 2 жыл бұрын
Sorry, I don't think I understand the question? What do you mean by initialize the progress bar?
@sim-card8685
@sim-card8685 2 жыл бұрын
@@LlamAcademy I think the progressbar is default set to "null" so we should get a nullreference exception. But you don't get that. So it was set to a value before. But where have you done that? Have you used GetComponent?
@LlamAcademy
@LlamAcademy 2 жыл бұрын
Oh. I assigned it in the inspector
@sim-card8685
@sim-card8685 2 жыл бұрын
@@LlamAcademy Thanks. I have not seen that you marked it as public or [SerializeField]
@sim-card8685
@sim-card8685 2 жыл бұрын
@@LlamAcademy Ohhh now i see... i was confused because the attribute is on top of it thanks
@XifYz
@XifYz 10 ай бұрын
I love how he never shows nor explains the script that makes the health bars actually "follow" units.
@LlamAcademy
@LlamAcademy 10 ай бұрын
Hmm... I thought I did towards the end. If not, you can see it here: github.com/llamacademy/worldspace-health-bars/blob/main/Assets/Scripts/FollowTarget.cs it's a very simple script on Update just setting the position to the target positon + some offset.
@marcamooo
@marcamooo 2 жыл бұрын
why am i early?
@LlamAcademy
@LlamAcademy 2 жыл бұрын
Sorry what do you mean?
@marcamooo
@marcamooo 2 жыл бұрын
@@LlamAcademy idk im just like never early
@Akhazy0
@Akhazy0 8 ай бұрын
you make the most confusing video tbh
@LlamAcademy
@LlamAcademy 8 ай бұрын
👍
@bensalter7997
@bensalter7997 2 жыл бұрын
Sorry for what I did.
@xticxs4656
@xticxs4656 Жыл бұрын
this is the first time ive disliked a video because why do i have to watch 3 other videos just do this one
@LlamAcademy
@LlamAcademy Жыл бұрын
Sorry you feel that you had to watch several other videos. In the first few seconds of the video I set expectations that this video would be focused on the health bar following the target, not implementing explosions, AI spawning and wandering, and implementing a progress bar. That video would be closer to an hour and most people would be skipping 90% looking for what I tried to focus the video on. The full project for all of my videos are always on GitHub, so you can review the project on your own computer at your own pace after the guided tutorial video.
How to Avoid Ghost Collisions | Unity Tutorial
10:04
LlamAcademy
Рет қаралды 3,8 М.
Quando eu quero Sushi (sem desperdiçar) 🍣
00:26
Los Wagners
Рет қаралды 15 МЛН
It works #beatbox #tiktok
00:34
BeatboxJCOP
Рет қаралды 41 МЛН
Quando A Diferença De Altura É Muito Grande 😲😂
00:12
Mari Maria
Рет қаралды 45 МЛН
99.9% IMPOSSIBLE
00:24
STORROR
Рет қаралды 31 МЛН
Place UI Elements in your World! (Health Bar, Overlays, Timers)
7:26
HEALTHBAR in Unity - [Unity Tutorial]
6:41
Tarodev
Рет қаралды 52 М.
Health Bar Unity Tutorial in 7 Minutes | DevLog 5
7:27
BlackCitadel Studios
Рет қаралды 23 М.
10 Things You NEED to Be Doing in Unity
11:40
Tarodev
Рет қаралды 137 М.
Three Cool Health Bars in Unity (2024/2020)
6:14
CDisco
Рет қаралды 61 М.
Unity Architecture for Noobs - Game Structure
16:24
Tarodev
Рет қаралды 208 М.
Unity : 3D UI in World Space
7:31
about game making
Рет қаралды 120 М.
How to make a Save & Load System in Unity
26:56
Shaped by Rain Studios
Рет қаралды 207 М.
How to make AWESOME Scene Transitions in Unity!
19:45
Brackeys
Рет қаралды 966 М.
Quando eu quero Sushi (sem desperdiçar) 🍣
00:26
Los Wagners
Рет қаралды 15 МЛН