Тёмный

How to build a Health bar for Unreal Engine 5 the right way - Beginner Tutorial 

LeafBranchGames
Подписаться 21 тыс.
Просмотров 12 тыс.
50% 1

Tired of tutorials teaching bad habits? In this episode we will point out bad habits and good habits and things to take into consideration while we go through how to build a health bar for Unreal engine 5. This is aimed at beginners but has some more advanced concepts too.
00:00 Intro
00:15 Demonstration
00:35 Introduction and assets
03:03 Implementing health system
05:49 Create health bar widget
11:44 Add widget to viewport
15:57 Why bindings are bad
20:00 Communicate health value to health bar
27:35 Outro
Asset download: wenrexa.itch.io/darkmiko
Join the Discord server here: / discord
Support the work of LeafBranchGames on Patreon here: / leafbranchgames

Опубликовано:

 

26 июл 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 186   
@maglerdon
@maglerdon Год назад
I like how you demonstrated that binding is inefficient. All it took was printing every time that binding was called and it was immediately obvious why it's bad to do it that way. I think it would be cool if you did more videos like this. I'm new to Unreal so I've been following a lot of tutorials and I have no idea if I'm learning bad habits. I like how you took a method that many other tutorials recommend and explained why it's bad and how to do it more efficiently!
@LeafBranchGames
@LeafBranchGames Год назад
Thank you. I do try to explain good habits and point out bad habits as much as I can remember to do so in most of my videos, although maybe not as explicit as in this one. Anyway, glad to hear you like it, and keep on learning those good habits. :)
@offirbaruch7895
@offirbaruch7895 Год назад
I second that!
@jakedubs
@jakedubs Год назад
@@LeafBranchGames Interesting. Kekdot's channel just cast to the player on Event Construct, then set the Character as a variable inside the Health Widget. You can then use that variable in the binding function without casting every frame because you have a reference.. But It's not working well in multiplayer atm. So now I'm here. Any thoughts?
@LeafBranchGames
@LeafBranchGames Год назад
@@jakedubs You can cast at begin play to avoid a cast being done every frame. But that is just part of the issue.If you have a binding at all, all that code will run on tick even when no change is done, which is just wasted performance. It is more convenient, but it is not good. You could just watch my tutorial on health bars for multiplayer: ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-OGbkAF504Gw.html
@winterpixl
@winterpixl 5 месяцев назад
Love your content. I had no idea bindings ran every tick. Keep up the amazing work!
@LeafBranchGames
@LeafBranchGames 5 месяцев назад
Thank you. Glad to hear you learned something new. :)
@Rat_Lord
@Rat_Lord Год назад
My god. I had no idea bindings were called every frame. My whole UI setup is using bindings currently. Back to the drawing board lol. Love your channel! Thank you for all the great info and hard work!
@LeafBranchGames
@LeafBranchGames Год назад
Thank you for the kind words. Appreciate it a lot. :)
@kellowattentertainment
@kellowattentertainment 9 месяцев назад
One year later and your tutorials are still fire bro... this saved me so much headache
@LeafBranchGames
@LeafBranchGames 9 месяцев назад
Thank you, glad to hear it. :)
@youdungoofed1
@youdungoofed1 Год назад
You are the first person I've found that shows how to make a health bar without binding. You even take the time to show why it's very bad for optimization. Thank you. You saved me and have earned a sub.
@LeafBranchGames
@LeafBranchGames Год назад
Thank you for your support. :)
@jakedubs
@jakedubs Год назад
You could also use Blueprint Interface messages for event driven logic, but this way is better.
@aethylwulfeiii6502
@aethylwulfeiii6502 7 месяцев назад
Sorry but it doesn't actually work as soon as you try to make a character respawn!
@Smile1oasis
@Smile1oasis Год назад
I always used to think why everyone just doing some way and not explaining why they are doing so. Here I can see you put effort on explaining why you should not do one method and also doing the right and in more efficient way! You have earned a sub 😇👏
@LeafBranchGames
@LeafBranchGames Год назад
Thank you for your support. :)
@BlackG0lem
@BlackG0lem Год назад
Great tutorial! Thanks so much for showing how casting and binding could be inefficient! Keep up the great work!
@LeafBranchGames
@LeafBranchGames Год назад
Thank you. :)
@vinutisfalse2527
@vinutisfalse2527 2 года назад
thank you for making content so fast i hope you get more subs
@syno3608
@syno3608 2 года назад
Indeed ...
@LeafBranchGames
@LeafBranchGames 2 года назад
Thank you. I appreciate that. :)
@pulkit1437
@pulkit1437 10 месяцев назад
great content, explaining bad and good of anything and everything you implement is always a delight to see ^^ also when we getting the update on your project :D Kepp up the good work !
@LeafBranchGames
@LeafBranchGames 10 месяцев назад
Thank you. Appreciate that! Unfortunately the project had to be halted. Unsure if it will be resumed again. :(
@pulkit1437
@pulkit1437 10 месяцев назад
@@LeafBranchGames Ah, I was pretty pumped to hear about it again. Still I believe in your capabilities maybe make something? You are filled with all the ideas and how to tackle problems ALL MY SUPPORT TO YOU MY GUY!
@LeafBranchGames
@LeafBranchGames 10 месяцев назад
@@pulkit1437 I might look into doing a much smaller project that I can manage to finish myself. Time will tell. :) The support is appreciated!
@ithilien8103
@ithilien8103 Год назад
I would be ready to pay for a tutorial of a fantasy game, like souls -like game or such. Your way of teaching things is A-class and the Unreal community really needs someone like you who shows how things are done correctly and efficiently. Unreal engine is really hard to learn and let's face it, there's not enough discussion and helping of each other out like in Unity community. Big thanks to you.
@LeafBranchGames
@LeafBranchGames Год назад
Thank you for the kind words. Maybe my RPG series is something along the lines of what you are looking for? ru-vid.com/group/PLNBX4kIrA68lz8GSxTQKX_0B23tHP6Bl9
@pwnonator
@pwnonator 5 месяцев назад
Very nice tutorial man,
@LeafBranchGames
@LeafBranchGames 5 месяцев назад
Thank you!
@BeamFreqGames
@BeamFreqGames 6 месяцев назад
A++ tutorial. Thank you much. God bless.
@LeafBranchGames
@LeafBranchGames 6 месяцев назад
Thank you kindly!
@Mohit_N.R
@Mohit_N.R Год назад
You Just Saved Me !! Thanks !!
@LeafBranchGames
@LeafBranchGames Год назад
My pleasure. :)
@darkwraithcovenantindustries
@darkwraithcovenantindustries 4 месяца назад
so many tutorials teach bad habits! It's wild, and so difficult to tell as a beginner who is legit and who doesn't really understand the engine all that well and is trying to make a career out of it. I've already run into one guy who makes a few glaring, nonsensical mistakes in his tutorial, like nodes that don't do anything, and nodes that do the opposite of what he says they do. Thanks so much for teaching the proper way to do things!
@LeafBranchGames
@LeafBranchGames 4 месяца назад
Thank you! Appreciate the feedback and kind words. :)
@Daniel-sn5se
@Daniel-sn5se 3 месяца назад
Jesus, that is so true! Even worse because 99% of time these bad tutorials have good revievs with milion of people thanking for the solution that turns out is just a LAZY version of proper working solution. Thank you @LeafBranchGames for taking time and explaning to us things ''behind''.
@LeafBranchGames
@LeafBranchGames 3 месяца назад
@@Daniel-sn5se Glad to be of help. :)
@RolyPolyGames
@RolyPolyGames Год назад
Yup good video, doing this stuff in c++ myself. Good to know I was correct that binding was a bad idea cause it was on tick.
@LeafBranchGames
@LeafBranchGames Год назад
Glad I could be of help. :)
@KeithKazamaFlick
@KeithKazamaFlick 2 года назад
best channel!
@LeafBranchGames
@LeafBranchGames 2 года назад
Thank you kindly. :)
@Pefect
@Pefect Год назад
Thank you :)
@LeafBranchGames
@LeafBranchGames Год назад
My pleasure. :)
@Conversation_Dev
@Conversation_Dev 2 года назад
great topic
@LeafBranchGames
@LeafBranchGames 2 года назад
Thank you. :)
@davejones2227
@davejones2227 2 года назад
Hi, thanks for all the tutorials (and for answering some of my questions of the UE Reddit)! I was wondering if you plan to do a tutorial on inventory systems? There are a few out there but they're mostly focused on MMO stuff rather than on something like Breath of the Wild or Outer Worlds, for example. I find these are well designed for both PC and consoles. All the best!
@LeafBranchGames
@LeafBranchGames 2 года назад
I have an inventory system on my channel. I will probably be making an improved inventory soon, but it should teach most aspects related to inventories.
@davejones2227
@davejones2227 2 года назад
@@LeafBranchGames Oh apologies, I did check through but I must have missed it! I'll be sure to go back and have a look :)
@davejones2227
@davejones2227 2 года назад
@@LeafBranchGames I just found the inventory system, thanks for making it - it's actually the exact system I wanted! Many thanks :D
@LeafBranchGames
@LeafBranchGames 2 года назад
@@davejones2227 No problem.
@klimaluky
@klimaluky 2 года назад
Sadly nothing new for me, but really appreciate way of showing how should be done right from start! :)) Binding is one of that things which are like ticking bombs waiting to destroy your week when project grows enough :]
@LeafBranchGames
@LeafBranchGames 2 года назад
Indeed. Sorry I could not impart any new knowledge this time. Maybe next time. :)
@klimaluky
@klimaluky 2 года назад
@@LeafBranchGames Definitely, looking forward for it! :]
@AMobOGobos
@AMobOGobos Год назад
I have implemented this with my character, but I can't find a way to make it work for an enemy (since they do not inherit from the player controller). Do you have a video on how to add updating health bars to enemy actors, or some advice on how to do it?
@LeafBranchGames
@LeafBranchGames Год назад
Yes, AI don't have any player behind a screen so there is no point to have a UI for them. So instead what is usually done is either a player has an enemy widget as part of their UI so that you can see life remaining, or you have a widget in the world near the enemy to represent the life. So depending on how the enemy health is implemented to be shown, requires different solutions.
@tastysnak
@tastysnak 2 года назад
Thanks for demonstrating how binding is not the way to go when it comes to doing things like this. I had no idea binds run on every tick! I am currently experimenting with different way of accomplishing the same thing within the engine, but have no way of knowing which is the better or more efficient method. Do you know much about how to identify performance issues in the engine and how to fix them?
@LeafBranchGames
@LeafBranchGames 2 года назад
For these kinds of things you won't likely spot it until you have a lot of UI elements that all collectively take up a significant amount of performance. In general, there are some visualization tools that can let you see if your environment is heavy in different ways. There are also profiler tools that let you see where bottlenecks are appearing for your per frame calculations.
@retrowrath9374
@retrowrath9374 Месяц назад
Thanks for the video. Is there a way to use text going down instead of a health bar?
@LeafBranchGames
@LeafBranchGames Месяц назад
Of course. Everything is possible in programming.
@TerribleMighty1
@TerribleMighty1 Год назад
Thank you for this video; I’ve been looking around for this specific demo (on how NOT to use bindings for health). However, I make it to the end and try to update the starting health on EventBeginPlay using the function you created …but it just doesn’t update. I start the game and it only matches whatever I have the percent slider set to in the progress bar widget . What am I missing??
@LeafBranchGames
@LeafBranchGames Год назад
I can't be sure. This would most easily be found out by debugging the problem. If you do not know how debugging is done, I have a introduction to the basics of debugging here: ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-zN7XOSlxAJA.html
@TerribleMighty1
@TerribleMighty1 Год назад
@@LeafBranchGames thank you for the reply!! I think I figured out why it is happening (but don’t know how to fix it). When I was running the viewport , I noticed the debug objects for the character and widget blueprints both have TWO debug objects each. Nodes fire on one object but not the other. For example there’s “Widget_0” & “Widget_1” in the debug objects. Only “_1” is firing the nodes correctly. But on the character side , only “_0” is firing “damage”. Hope this isn’t too confusing 🙄
@LeafBranchGames
@LeafBranchGames Год назад
@@TerribleMighty1 Are you following the tutorial or are you applying the tutorial on a project of your own?
@TerribleMighty1
@TerribleMighty1 Год назад
@@LeafBranchGames no , I came here after I had a project setup and going. I just figured it out though. I had a spawner Actor who was causing the duplicate characters and widgets. So the widget actually was updating, just not on MY character. I’ve since removed the spawner and manually placed the character on the tile set. It all works great now!
@LeafBranchGames
@LeafBranchGames Год назад
@@TerribleMighty1 Glad to hear you sorted it out.
@IsaacCode95
@IsaacCode95 Год назад
thank you !, great tutorial, first time learning about event dispatchers lol i did so much casting. any tips on how to make the health bar widget do a smooth 'health drop' and not snap down ?
@LeafBranchGames
@LeafBranchGames Год назад
Thank you. Sure, you can do it several ways. You can animate a material if that is how you display the progress bar. Or you could use a timer which starts ticking when you change the value. You need to keep track of your current value and your target value. Then when the timer each time get called you move it slightly towards your target value.
@IsaacCode95
@IsaacCode95 Год назад
@@LeafBranchGames animating the material is interesting ! i really thought a lerp or sometihng lol
@LeafBranchGames
@LeafBranchGames Год назад
@@IsaacCode95 Yes, lerp in the timer. You can do a lot of cool stuff with materials though.
@yucekaracagil3167
@yucekaracagil3167 Год назад
Hello, I really liked the way you showed this in detail. I have a question. I have created a BP called UIHUD and put it in the scene so there is no characters to cast. So when I try to cast like you did at the end, can't find a suitable object as I cannot call get player controller or anything. (coz there is none in that blueprint) and I won't have a character in the game, (its an incremental game) so how can I overcome this problem? Got any idea?
@LeafBranchGames
@LeafBranchGames Год назад
Yes, you can call get player controller. I got the player pawn, because that is where I stored the relevant variables for the widget. If you don't have a pawn, then you have those in the controller or an object the controller knows of.
@yucekaracagil3167
@yucekaracagil3167 Год назад
@@LeafBranchGames Thanks for quick response
@LeafBranchGames
@LeafBranchGames Год назад
@@yucekaracagil3167 No problem, good luck!
@Alloart3D
@Alloart3D 3 месяца назад
Really liked the tuto, ut i try to add that technic to my enemies and it doesn't work, i can't figure out the last part, how to translate it to an AI.
@kimped5
@kimped5 Год назад
Nice tutorial! Could you make a tutorial based on this when the health bar reaches zero then game over or quit game?
@LeafBranchGames
@LeafBranchGames Год назад
I have a game over tutorial here: ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-LyVv55IE4r0.html You can combine the logic here with that one when your HP reaches zero.
@Drakuba
@Drakuba Год назад
18:25 sadest thing is i saw 2 other HP tutorials that did it exactly wrong, while both having 100k + subs
@LeafBranchGames
@LeafBranchGames Год назад
Yes, this is very unfortunate. Many of the largest channels teach really bad practices in many situations. :/
@Drakuba
@Drakuba Год назад
A lot of other channels also teach unpractical things, as if they teach for the sake of teaching instead of for sake of making functional things. Im glad i found this channel, keep up the good work👍
@LeafBranchGames
@LeafBranchGames Год назад
@@Drakuba Glad to hear it, thank you for your support. :)
@ihatekasper
@ihatekasper Год назад
in the W_HealthBar Event Graph, if you were doing a health bar for an enemy rather than the player, what would you do instead of "Get Owning Player Pawn"?
@LeafBranchGames
@LeafBranchGames Год назад
An AI can't have a UI, so it would never be getting owning player pawn. Since there is no person watching the screen for the AI, showing a UI would be pointless. So what you are instead trying to do is show a widget for non-AI players, that want a visual representation of some property of the AI in question.
@AMobOGobos
@AMobOGobos Год назад
@@LeafBranchGames This IS what I want to do, but I still don't know how to do it.
@naytbreeze
@naytbreeze Год назад
Tried following these steps and watched other videos that are similar. For some reason I cannot get the UI to show on my viewport. I've tried the exact steps did something change? I watch another video and the person added the UI interface but called it to the view port by using a different controller then changing the viewport settings to that new controller but that way seems a bit odd to me. Any ideas what I am doing wrong.?
@LeafBranchGames
@LeafBranchGames Год назад
It depends a little on your circumstances. When you create a widget you can assign which controller it should belong to as input. Make sure to send the player controller that should show it as that input and you should be good.
@gaarasabaku3236
@gaarasabaku3236 4 месяца назад
Thank you so much, this is vary helpfull! If i want to restore the Health whit a healing pickup item I have to create a new event dispatches for make it work?
@LeafBranchGames
@LeafBranchGames 4 месяца назад
No, you just change the health value. You can look at my Create an RPG series if you want more in depth knowledge how to make complex health systems and have them communicate with UI like this.
@gaarasabaku3236
@gaarasabaku3236 4 месяца назад
@@LeafBranchGames Thank again man, I will look into it.
@LeafBranchGames
@LeafBranchGames 4 месяца назад
@@gaarasabaku3236 Good luck!
@RendoForlean
@RendoForlean Месяц назад
i have a question though, as you can see it's very cluncky, how would you smooth out the movement of the progress bar? i really dont wanna use tick lol
@LeafBranchGames
@LeafBranchGames Месяц назад
It is not clunky, it is 100% accurate. However if you want to have a gradual transition between two specific values, you can have that either done in the UI or in a material for example.
@familieboon3876
@familieboon3876 8 месяцев назад
Hi, great tutorial, I'm new to the engine and I have a question. My EventBeginPlay is allready used by my movement input. Is there a way to fix that? because I have noticed I can only use the same 'Event' node once in a blueprint So I can't use it for the widget.
@familieboon3876
@familieboon3876 8 месяцев назад
I think I have a solution for now, I have teh Event Tick on the Character movement and the EventBeginPlay on the widget on for now it works fine
@LeafBranchGames
@LeafBranchGames 8 месяцев назад
@@familieboon3876 You can only have an event once, yes. But you can sequence code in that event to make use of it for many different things. I explain a bunch of ways of doing that in this tutorial: ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-FRDmlc_2txg.html Other than that, I highly recommend not using event Tick unless you REALLY need to. Many bad tutorials teach you using tick, but it is an event that should be used very sparingly.
@familieboon3876
@familieboon3876 8 месяцев назад
Thanks for the quick reply, I will give it a try
@LeafBranchGames
@LeafBranchGames 8 месяцев назад
@@familieboon3876 Good luck!
@HumpaLumpaBiriBam
@HumpaLumpaBiriBam 4 месяца назад
The only reason why I would use binding in UI is formatting. i.e: at @17:30 I get it, not casting or excessive calculations. but you can store local variables in UI and just do percentage "formatting" in binding function. OR create "binding to local variable" without function! I see in UE53 I can do that. I wonder if that's more efficient? Then either create custom Event in UI that will run formatting and update health bar OR do through event dispatcher as you did. If hit is taken then notify UI and update its local values. Damage or health up values are int/float, easy to debug & setup. but presentation logic could be done in UI. For now its health bar... but at some point you might want to change it to display health points or both. This way its easy to handle all data presentation in UI.
@LeafBranchGames
@LeafBranchGames 4 месяца назад
You of course have to adapt your communication and interfaces to the needs of your project. But a UI binding should never really be used.
@HumpaLumpaBiriBam
@HumpaLumpaBiriBam 4 месяца назад
@@LeafBranchGames OMG moment.. Just found exactly what I wanted! Please check out "viewmodel" plugin(by epic, beta) that enable view-model design pattern. Update variables with clear separation dev / ui designer. And fields are updated thanks to Field Notifier!. MAGIC! Maybe its worth to make youtube video for it? Please check this out.
@redfoxsis
@redfoxsis Год назад
Please can you make a sequel to make a health pick-ups
@EMBakie
@EMBakie Год назад
I can't seem to get another "Event beginPlay" to be added to the 3rd person blueprint. It just jumps me back to the original one that is already there by default, and my only other option is to create a custom event instead. Am I missing something?
@LeafBranchGames
@LeafBranchGames Год назад
You don't want to have multiple begin play events. One is enough. Put your begin play logic there.
@EMBakie
@EMBakie Год назад
Gotcha, I'll give it a shot. Where do I go and attach it from exactly? 🤔 It already has a cast to player controller going on. Is there a way to branch off and create the widget but not mess with the input mapping?
@LeafBranchGames
@LeafBranchGames Год назад
@@EMBakie Input mapping is separate. You use the cast player controller reference for the widgets/HUD.
@jameswilliams2373
@jameswilliams2373 2 года назад
awesome as usual mate things like this really help people like me, quick question I'm using the right thumbstick for rotation in a top down shooter everything works fine i was wondering how i would implement the z axis so i can aim anywhere do you know of a way to do this cheers.
@LeafBranchGames
@LeafBranchGames 2 года назад
You could have auto aim so that when you shoot in a direction where an enemy is and it is at a different z-elevation, adjust the firing angle up or down for you.
@jameswilliams2373
@jameswilliams2373 2 года назад
@@LeafBranchGames thanks thats a good idea, is there a way to do it manually though like a mouse would
@LeafBranchGames
@LeafBranchGames 2 года назад
@@jameswilliams2373 Sure, you can just trace under a mouse cursor or aim cursor and see what height the trace finds a hit.
@jameswilliams2373
@jameswilliams2373 2 года назад
@@LeafBranchGames awesome thanks man would you ever consider doing some top down tutorials
@LeafBranchGames
@LeafBranchGames 2 года назад
@@jameswilliams2373 There will be some of that in the future as well, sure.
@50shadesofskittles9
@50shadesofskittles9 2 года назад
I'd love to binge your videos but hammering your keys is such a distraction. You might wanna learn how to filter those sounds out a bit. Very easy to do in broadcast software such as OBS and Slobs.
@LeafBranchGames
@LeafBranchGames 2 года назад
Tried that. Couldn't get it to cut the keys without making my voice cut in and out too aggressively.
@karlschneider8451
@karlschneider8451 Год назад
Great Video brother. I was having issues after binding my widget. I deleted my binding and formula after watching that portion of your video. I am still having an issue though where the health bar stays the same when I am playing the game. I threw a print string at the end of my health bar widget logic and it doesnt fire when taking damage. I did a print screen for when I am taking damage and it shows my health dropping so its a communication issue with the widget. Got any advice on troubleshooting or things to double check?
@LeafBranchGames
@LeafBranchGames Год назад
So if the communication does not reach the event that is supposed to fire when you take damage, then that means the binding was not set up properly. So I would debug when the code for binding of the event is to be run,. and make sure that both the object it is binding the event to is a valid object reference but also that it is the object that you are intending to bind to.
@karlschneider8451
@karlschneider8451 Год назад
@@LeafBranchGames is there a debug to test if it’s broadcasting properly?
@karlschneider8451
@karlschneider8451 Год назад
Oh I just found the issue! I didn’t connect my event construct at the beginning of my widget graph! Btw thank you for answering right away and explaining everything so well! Your explanations give us insight on why we are using what we are using so when we run into issues we can find them. Showing us when to test print screens and how to debug helps out so much. For this instance I knew the damage was working from testing I was just not getting the communication portion correct. I also really like the time stamps you have in the videos as I went right to the communication portion! Again thank you and keep up the good work!
@LeafBranchGames
@LeafBranchGames Год назад
@@karlschneider8451 Glad to hear you resolved your issue. Thank you for the kind words. :)
@faze0ne844
@faze0ne844 Год назад
i have a simple potion blueprint but im having a hardtime connecting the two
@leons1412
@leons1412 Год назад
Hi! Do you think you could do a tutorial on how to make MOBA stylized health bars? The ones which look divided and give you an idea of how much health the character has without a number, just knowing each division equals X a mount of health? I hope I'm explaining myself adequately 😅
@LeafBranchGames
@LeafBranchGames Год назад
I assume you mean that the health bar has sub segments in the health bar instead of one full progress bar? Or maybe limiting lines that show 25%/50%/75% positions?
@leons1412
@leons1412 Год назад
@@LeafBranchGames I never saw you answered 😱 Sorry. I mean, the health bar having divisions let's say every 500 points, and when you gain more total health, the bar shows more of these divisions, letting everyone know that you have a bigger health bar than others with less divisions
@LeafBranchGames
@LeafBranchGames Год назад
@@leons1412 I can add the suggestion to my to do list, sure.
@DeftlyJ
@DeftlyJ 2 года назад
Is there are reason people don't put this on the controller instead of the player? Wouldn't putting it on the controller and using interfaces take away the need to cast?
@LeafBranchGames
@LeafBranchGames 2 года назад
Put what on the controller, the widget? Or the health? If you mean the health, then health is something that belongs to a character, not a player. The player could theoretically have the ability to change control to a different character. Then you want to make sure the health is reflected from the character you are currently controlling.
@madeeasy7148
@madeeasy7148 Год назад
MY Health starts in the game as whatever value was set in the widget hud, when i take take damage it jumps up to what i set in the blueprint?then starts decreasing when im in the pain volume
@LeafBranchGames
@LeafBranchGames Год назад
Yes, this is explained in the end of the video.
@sharkwatcher9740
@sharkwatcher9740 3 месяца назад
I really appreciate all of your tutorials. I am trying to implement this but I am having trouble. If I am using a separate blueprint component for damage/health, how would I implement that instead of storing health as a variable in the player character? I tried to do the player cast, then pulled from my component, then tried to get the variables there but it did not work. Any help would be greatly appreciated.
@LeafBranchGames
@LeafBranchGames 3 месяца назад
I setup a complete and flexible stat component in this tutorial series, along with a lot of other useful learning, not only if you are into RPGs: ru-vid.com/group/PLNBX4kIrA68lz8GSxTQKX_0B23tHP6Bl9
@sharkwatcher9740
@sharkwatcher9740 3 месяца назад
@@LeafBranchGames yes I did the full tutorial and learned a tremendous amount from it. Your channel has consistently been the one I've turned to for proper coding information that is up to date. But I needed to learn more about complex AI so I followed some other tutorials out there. I tried to make the two systems work but I've made more problems than I've solved so I'm planning on scrapping that and going back to your foundation and building on that again. If I may ask though, in the rpg framework that you built, when I am trying to implement specific damage for different actors or different attacks, is there a best practice for that? I didn't know if I should make a function in the bpc_combat component to calculate different damages. Thank you very much for all of your help and tutorials.
@LeafBranchGames
@LeafBranchGames 3 месяца назад
@@sharkwatcher9740 Best practice in programming in general is that you have small classes that have one responsibility. So striving towards that kind of structure is the "best". BPC combat is a bit bloated with functionality, so breaking out parts may be useful. You could have a damage calculating class that handles how to calculate damage between actors.
@sharkwatcher9740
@sharkwatcher9740 3 месяца назад
@@LeafBranchGames awesome thank you very much for your time.
@LeafBranchGames
@LeafBranchGames 3 месяца назад
@@sharkwatcher9740 No problem!
@MaMa-rc4eo
@MaMa-rc4eo Год назад
its crazy how many bad habits you will find when searching for solutions in unreal engine. this case is simple one, but i encountered so many way more problematic ones on my learning jorney. and there is a huge lack of stored knowledge. if i ask questions to best practices (in professional environments) i get no answers. i feel like i need to join a company or university first to get taught this stuff...research seems to be very difficult in this industry.
@LeafBranchGames
@LeafBranchGames Год назад
It is mostly a matter of looking in places where the knowledge is there. Some people know the engine well, some know materials, some know lighting, some don't know any of it but still "teach".
@alexstewart9215
@alexstewart9215 5 месяцев назад
great vid, I didn't realise I was making a huge mistake when following the aforementioned tutorials. I have a problem though, when I try to create a custom event and bind it to the called event it says "Delegate (by ref) is not compatible with Delegate"
@alexstewart9215
@alexstewart9215 5 месяцев назад
ok I watched that part again and noticed how you got it this time, but my health isnt updating. I checked that the damage event is firing by putting a print at the end of it and that works.
@LeafBranchGames
@LeafBranchGames 5 месяцев назад
@@alexstewart9215 You can start with making sure the values for health are being set properly. If that is being done then you missed something in the the communication to the UI. You can either debug to see if you can locate the issue, I have plenty of tutorials on debugging, or you can rewatch the tutorial to make sure you do everything like shown.
@alexstewart9215
@alexstewart9215 5 месяцев назад
@@LeafBranchGames I figured it out, "get owning player pawn" wasn't working for me but " get player pawn" is? would it be bad if I kept it like this?
@LeafBranchGames
@LeafBranchGames 5 месяцев назад
@@alexstewart9215 Get player pawn is different because it will be getting a pawn based on an index, which will not work if there are multiple human players.
@Drakuba
@Drakuba Год назад
Do you have a video explaining the function : "Get owner" , " get controller", "Owning player" or the ones in this line of work? From what i noticed they are there to specify who is the code to be applied to, but i cant wrap my head around them. Some other tutorials use them as well, but only those who dont use ticks. When they rely on ticks theres no mention of those functions. Do you have a deep dive or some other explanation on those?
@LeafBranchGames
@LeafBranchGames Год назад
I do not yet have tutorials specifically on the topic. I tend to mention and explaining it as part of other tutorials now and then.
@Drakuba
@Drakuba Год назад
ill try to look into them myself. Everytime i see them theres just something not clicking for me, which is bugging me since they seems super suefull. Its just your videos really sit with me and i was wondering since i couldnt find anything in your playlist Thanks anyway
@LeafBranchGames
@LeafBranchGames Год назад
@@Drakuba I will be making some new playlists, explaining basic key parts and other foundational important aspects. There is just so much I want to cover. :)
@Drakuba
@Drakuba Год назад
No rush, but those will be greatly appreciated ;)
@danielgondos3689
@danielgondos3689 2 года назад
Of the bind is called every tick, whats the usecase where it is actually useful?
@LeafBranchGames
@LeafBranchGames 2 года назад
If you have some UI element that uses logic that is likely going to be updated every frame, then you may as well make use of it. But even in those cases other considerations apply. Since it is going to be run every tick, you should make sure that the logic that is run is as performant and small as you can make it.
@danielgondos3689
@danielgondos3689 2 года назад
​@@LeafBranchGames its so weird that an off-the-shelf unreal feature is such a poor decision to use. I would love it, if the easy way would be the right way. e.g.: the bind would look the same, but it wouldnt run on tick. only when the used variables changed. if it uses dispatchers under the hood, i wouldnt care, but would be nice to hook up information performantly, without littering everything with dispatchers and belonging nodes.
@LeafBranchGames
@LeafBranchGames 2 года назад
@@danielgondos3689 Many features that are available can be bad if used wrong. Just like how you can see plenty of tutorials to hook all logic into the tick event. Sure that works, but just like with binds, it is probably not the best solution and it will cause performance issues as you keep adding classes that has the same approach. "Easy" is usually an indicator that you may have cut some corner that might cost you later down the line. :)
@raw2wmobile.legends773
@raw2wmobile.legends773 Год назад
So this tutorial wont work when im trying to make a multiplayer game. Any advice?
@LeafBranchGames
@LeafBranchGames Год назад
Sure it will. You may want to create the HUD and the setup on a different event, like on possessed when the controller take control over a pawn instead because a multiplayer game doesn't load in the same way as an in editor demonstration.
@koldunas8
@koldunas8 5 месяцев назад
I love Your approach, but I am running into a problem with implementing this in local coop game. where player 1 healthbar functions as intended, while player 2 does not update at all (player still takes damage). With binding it used to work fine.
@LeafBranchGames
@LeafBranchGames 5 месяцев назад
You probably want to watch a multiplayer tutorial for health bar instead: ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-OGbkAF504Gw.html
@koldunas8
@koldunas8 5 месяцев назад
@@LeafBranchGames As far as I understand it's for multiplayer on server. Mine is local couch coop with several controllers. I will try this method soon enough though.
@KavanBahrami
@KavanBahrami 2 года назад
Thanks for posting. Quick comment. When you say "lets do it the right way" then start the tutorial with saying 'you shouldn't do it this way, but I am for the sake of simplicity' 3:10 its odd ;)
@LeafBranchGames
@LeafBranchGames 2 года назад
Agreed. But creating a whole health system for the sake of a tiny health bar felt overkill. :)
@faze0ne844
@faze0ne844 Год назад
how can i create a potion pickup with this health bar ?
@LeafBranchGames
@LeafBranchGames Год назад
A potion pickup is completely separated from the health UI. All the potion will do is change the health, which the UI will handle itself when the event dispatcher is called. So you only have to code your logic for the potion affecting the health and you are done.
@faze0ne844
@faze0ne844 Год назад
@@LeafBranchGames if ever you want can you give us a little exemple , i tried taking variables from your setup on an actor potion pickup with a box collider, but im having a hard time actually getting the potion to give back health ! , i made the pain collider and everything works fine, but the potion , dont seem to give back health
@LeafBranchGames
@LeafBranchGames Год назад
@@faze0ne844 You can have either have your potion call the damage event with negative value or you can make a new function for healing which works similar to the setup of the damage event with event dispatcher.
@cvoiceofficial
@cvoiceofficial Год назад
Hmmm, how would I do this if my character manually spawns in after the level loads. The health bar doesn't update to full health.
@LeafBranchGames
@LeafBranchGames Год назад
The video shows how to update the health bar as the character spawns. You need to call the dispatcher when you want to update.
@cvoiceofficial
@cvoiceofficial Год назад
@@LeafBranchGames Well that's lame; apparently the issue is I needed a delay. Wish there was a way to do it without it. I am doing the function of on Possess, because the pawn doesn't get possessed right away
@LeafBranchGames
@LeafBranchGames Год назад
@@cvoiceofficial Shouldn't be a problem if you place it in the possess event on the character. Delays should almost never be necessary.
@cvoiceofficial
@cvoiceofficial Год назад
@@LeafBranchGames Don't know why, but for me the delay after the possess event is necessary. It's only at the default delay of .2 sec though
@LeafBranchGames
@LeafBranchGames Год назад
@@cvoiceofficial My advice would be, if you are interested in getting rid of the delay and also trying to get a better understanding, to debug why it doesn't work without the delay.
@Xspurr
@Xspurr Год назад
How do you do this with text?
@LeafBranchGames
@LeafBranchGames Год назад
Exactly the same way. But instead of a progress bar you have your text driven by the percentage.
@Xspurr
@Xspurr Год назад
@@LeafBranchGames The thing is that a text block doesn't get a variable, like the progress bar does, so I can't add functionality to it in the graph. I was however able to communicate, via dispatchers, to a variable (integer) and make the text show thoose numbers. I choose the variable under Content for the textblock, but I'm not sure if it is just another binding and just ticks away in the background. I hope that made sense!
@LeafBranchGames
@LeafBranchGames Год назад
@@Xspurr To set the text of a text widget you need to call the set text node on the widget component. Then that input would be what is displayed as text. So if you wanted to just show the percentile number you could use that as input after a conversion from percent to text.
@martinberge9237
@martinberge9237 2 года назад
Does it work for multiplayer?😊
@LeafBranchGames
@LeafBranchGames 2 года назад
UI and widgets only exist on local clients.
@pwnonator
@pwnonator 5 месяцев назад
I am confused because this video seems different when i watched it a few months ago.
@LeafBranchGames
@LeafBranchGames 5 месяцев назад
Maybe it was a different tutorial. I have quite some UI tutorials.
@MrDrazeTV
@MrDrazeTV Год назад
i cant set progressbar, i can only get it. why is this? this is driving me nuts.
@LeafBranchGames
@LeafBranchGames Год назад
In which context can you not get it?
@MrDrazeTV
@MrDrazeTV Год назад
@@LeafBranchGames When you drag out the progressbar_39 in the graph and chose get or set. I can only select "get". (24:06) On the left side where you can see the variables is says "public progressbar_39", but when i hover the mouse over it, it says that i cannot edit this variable cause its not public. I deleted everything (W_HUD and W_Healthbar blueprints) did everything again, followed your guide and still have the same issue. Im kinda sure its not public even it says it is, cause the "eye" icon on the variable is closed, and on yours its open.
@LeafBranchGames
@LeafBranchGames Год назад
​@@MrDrazeTV The eye icon is usually connected to if something is instance editable, which doesn't really apply for widgets. Clicking on the eye or the instance editable field would affect this icon. But since this is a widget that should not apply. I can not see how this would come to be, what version of UE are you using? Does this happen for all types of widget components you add or just progress bars?
@MrDrazeTV
@MrDrazeTV Год назад
@@LeafBranchGames Im using version 5.1.1, but i cant even open my project atm, it just crashes. I have no idea what is going on. Ill make a new project and see if that helps. Thanks for the support tho, really appreciate it.
@MrDrazeTV
@MrDrazeTV Год назад
​@@LeafBranchGames I created a new project. Still cant assign a value to the progressbar. Im giving up for the moment. Thanks for the help :)
@aethylwulfeiii6502
@aethylwulfeiii6502 7 месяцев назад
This tutorial is also terrible, everytime I respawn the player after they die, they end up with a health bar that is completely empty? Has anyone figured out how to fix this? Why is this simple stuff always so complicated and convoluted? After I set a branch boolean that if is dead is true then remove from parent target is widget? But it doesn't work!!! Your tutorial is just as bad when it doesn't explain this! There is no point to building a health system if it is not taken into context of death and respawning of the player.
@LeafBranchGames
@LeafBranchGames 7 месяцев назад
Your negative attitude is quite bizarre. The reason things don't work for you is your lack of knowledge, not the high quality tutorial. If you want something that brings along a context, then look for a tutorial like that instead of a single one that teaches you a specific thing. Here, this will teach you to make everything related; ru-vid.com/group/PLNBX4kIrA68lz8GSxTQKX_0B23tHP6Bl9
@darkwraithcovenantindustries
@darkwraithcovenantindustries 4 месяца назад
This tut is great, wdym. It never claimed to teach about what to do with a kill condition, but this is very easy to extend using this as the basis. You can set up an on killed event that happens when health < 0, to destroy the actor (self) in the BP of your player character. No need to be negative.
Далее
How I Remade MW2 with Unreal Engine 5
12:37
Просмотров 3 млн
How To Make A Health Bar In Unreal Engine 5
15:19
Просмотров 75 тыс.
Wait for the BOWLING BALL! 👀
00:38
Просмотров 17 млн
What Makes Tower Defence Games Good?
21:31
Просмотров 1,2 млн
Using Enums and BitFlags in Unreal Game Development
21:17
How to Create a Map EXTREMELY FAST in UE5
9:55
Просмотров 145 тыс.
Unreal Engine Materials in 6 Levels of Complexity
44:12