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

  Рет қаралды 11,690

LeafBranchGames

LeafBranchGames

Күн бұрын

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

Пікірлер: 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 11 ай бұрын
@@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 11 ай бұрын
@@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: kzbin.info/www/bejne/hXjFnHR8apVnfdk
@winterpixl
@winterpixl 4 ай бұрын
Love your content. I had no idea bindings ran every tick. Keep up the amazing work!
@LeafBranchGames
@LeafBranchGames 4 ай бұрын
Thank you. Glad to hear you learned something new. :)
@kellowattentertainment
@kellowattentertainment 8 ай бұрын
One year later and your tutorials are still fire bro... this saved me so much headache
@LeafBranchGames
@LeafBranchGames 8 ай бұрын
Thank you, glad to hear it. :)
@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 Жыл бұрын
thank you for making content so fast i hope you get more subs
@syno3608
@syno3608 Жыл бұрын
Indeed ...
@LeafBranchGames
@LeafBranchGames Жыл бұрын
Thank you. I appreciate that. :)
@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 11 ай бұрын
You could also use Blueprint Interface messages for event driven logic, but this way is better.
@aethylwulfeiii6502
@aethylwulfeiii6502 6 ай бұрын
Sorry but it doesn't actually work as soon as you try to make a character respawn!
@BeamFreqGames
@BeamFreqGames 5 ай бұрын
A++ tutorial. Thank you much. God bless.
@LeafBranchGames
@LeafBranchGames 5 ай бұрын
Thank you kindly!
@Mohit_N.R
@Mohit_N.R Жыл бұрын
You Just Saved Me !! Thanks !!
@LeafBranchGames
@LeafBranchGames Жыл бұрын
My pleasure. :)
@pwnonator
@pwnonator 4 ай бұрын
Very nice tutorial man,
@LeafBranchGames
@LeafBranchGames 4 ай бұрын
Thank you!
@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. :)
@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. :)
@KeithKazamaFlick
@KeithKazamaFlick Жыл бұрын
best channel!
@LeafBranchGames
@LeafBranchGames Жыл бұрын
Thank you kindly. :)
@pulkit1437
@pulkit1437 9 ай бұрын
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 9 ай бұрын
Thank you. Appreciate that! Unfortunately the project had to be halted. Unsure if it will be resumed again. :(
@pulkit1437
@pulkit1437 9 ай бұрын
@@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 9 ай бұрын
@@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? kzbin.info/aero/PLNBX4kIrA68lz8GSxTQKX_0B23tHP6Bl9
@Pefect
@Pefect Жыл бұрын
Thank you :)
@LeafBranchGames
@LeafBranchGames Жыл бұрын
My pleasure. :)
@Conversation_Dev
@Conversation_Dev Жыл бұрын
great topic
@LeafBranchGames
@LeafBranchGames Жыл бұрын
Thank you. :)
@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. :)
@darkwraithcovenantindustries
@darkwraithcovenantindustries 3 ай бұрын
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 3 ай бұрын
Thank you! Appreciate the feedback and kind words. :)
@Daniel-sn5se
@Daniel-sn5se 2 ай бұрын
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 2 ай бұрын
@@Daniel-sn5se Glad to be of help. :)
@davejones2227
@davejones2227 Жыл бұрын
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 Жыл бұрын
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 Жыл бұрын
@@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 Жыл бұрын
@@LeafBranchGames I just found the inventory system, thanks for making it - it's actually the exact system I wanted! Many thanks :D
@LeafBranchGames
@LeafBranchGames Жыл бұрын
@@davejones2227 No problem.
@klimaluky
@klimaluky Жыл бұрын
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 Жыл бұрын
Indeed. Sorry I could not impart any new knowledge this time. Maybe next time. :)
@klimaluky
@klimaluky Жыл бұрын
@@LeafBranchGames Definitely, looking forward for it! :]
@tastysnak
@tastysnak Жыл бұрын
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 Жыл бұрын
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.
@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.
@retrowrath9374
@retrowrath9374 6 күн бұрын
Thanks for the video. Is there a way to use text going down instead of a health bar?
@LeafBranchGames
@LeafBranchGames 5 күн бұрын
Of course. Everything is possible in programming.
@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.
@gaarasabaku3236
@gaarasabaku3236 3 ай бұрын
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 3 ай бұрын
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 3 ай бұрын
@@LeafBranchGames Thank again man, I will look into it.
@LeafBranchGames
@LeafBranchGames 3 ай бұрын
@@gaarasabaku3236 Good luck!
@jameswilliams2373
@jameswilliams2373 Жыл бұрын
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 Жыл бұрын
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 Жыл бұрын
@@LeafBranchGames thanks thats a good idea, is there a way to do it manually though like a mouse would
@LeafBranchGames
@LeafBranchGames Жыл бұрын
@@jameswilliams2373 Sure, you can just trace under a mouse cursor or aim cursor and see what height the trace finds a hit.
@jameswilliams2373
@jameswilliams2373 Жыл бұрын
@@LeafBranchGames awesome thanks man would you ever consider doing some top down tutorials
@LeafBranchGames
@LeafBranchGames Жыл бұрын
@@jameswilliams2373 There will be some of that in the future as well, sure.
@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!
@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: kzbin.info/www/bejne/gqq5p2hrfqpnqJI 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. :)
@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: kzbin.info/www/bejne/sH-aiYKJod10gKM
@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.
@Alloart3D
@Alloart3D 2 ай бұрын
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.
@familieboon3876
@familieboon3876 7 ай бұрын
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 7 ай бұрын
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 7 ай бұрын
@@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: kzbin.info/www/bejne/fIOnnp-ZlJenrsk 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 7 ай бұрын
Thanks for the quick reply, I will give it a try
@LeafBranchGames
@LeafBranchGames 7 ай бұрын
@@familieboon3876 Good luck!
@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.
@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. :)
@alexstewart9215
@alexstewart9215 4 ай бұрын
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 4 ай бұрын
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 4 ай бұрын
@@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 4 ай бұрын
@@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 4 ай бұрын
@@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.
@redfoxsis
@redfoxsis Жыл бұрын
Please can you make a sequel to make a health pick-ups
@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.
@sharkwatcher9740
@sharkwatcher9740 2 ай бұрын
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 2 ай бұрын
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: kzbin.info/aero/PLNBX4kIrA68lz8GSxTQKX_0B23tHP6Bl9
@sharkwatcher9740
@sharkwatcher9740 2 ай бұрын
@@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 2 ай бұрын
@@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 2 ай бұрын
@@LeafBranchGames awesome thank you very much for your time.
@LeafBranchGames
@LeafBranchGames 2 ай бұрын
@@sharkwatcher9740 No problem!
@HumpaLumpaBiriBam
@HumpaLumpaBiriBam 3 ай бұрын
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 3 ай бұрын
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 3 ай бұрын
@@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.
@RendoForlean
@RendoForlean 8 күн бұрын
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 8 күн бұрын
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.
@faze0ne844
@faze0ne844 Жыл бұрын
i have a simple potion blueprint but im having a hardtime connecting the two
@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 ;)
@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.
@danielgondos3689
@danielgondos3689 Жыл бұрын
Of the bind is called every tick, whats the usecase where it is actually useful?
@LeafBranchGames
@LeafBranchGames Жыл бұрын
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 Жыл бұрын
​@@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 Жыл бұрын
@@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. :)
@50shadesofskittles9
@50shadesofskittles9 Жыл бұрын
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 Жыл бұрын
Tried that. Couldn't get it to cut the keys without making my voice cut in and out too aggressively.
@koldunas8
@koldunas8 4 ай бұрын
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 4 ай бұрын
You probably want to watch a multiplayer tutorial for health bar instead: kzbin.info/www/bejne/hXjFnHR8apVnfdk
@koldunas8
@koldunas8 4 ай бұрын
@@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.
@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.
@DeftlyJ
@DeftlyJ Жыл бұрын
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 Жыл бұрын
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.
@MaMa-rc4eo
@MaMa-rc4eo 11 ай бұрын
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 11 ай бұрын
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".
@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.
@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.
@KavanBahrami
@KavanBahrami Жыл бұрын
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 Жыл бұрын
Agreed. But creating a whole health system for the sake of a tiny health bar felt overkill. :)
@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.
@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.
@martinberge9237
@martinberge9237 Жыл бұрын
Does it work for multiplayer?😊
@LeafBranchGames
@LeafBranchGames Жыл бұрын
UI and widgets only exist on local clients.
@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 :)
@pwnonator
@pwnonator 4 ай бұрын
I am confused because this video seems different when i watched it a few months ago.
@LeafBranchGames
@LeafBranchGames 4 ай бұрын
Maybe it was a different tutorial. I have quite some UI tutorials.
@aethylwulfeiii6502
@aethylwulfeiii6502 6 ай бұрын
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 6 ай бұрын
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; kzbin.info/aero/PLNBX4kIrA68lz8GSxTQKX_0B23tHP6Bl9
@darkwraithcovenantindustries
@darkwraithcovenantindustries 3 ай бұрын
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.
Урок 19 | Unreal Engine 4 Blueprint Interface - Обмен данными между блупринтами
15:18
Alat Seru Penolong untuk Mimpi Indah Bayi!
00:31
Let's GLOW! Indonesian
Рет қаралды 7 МЛН
Универ. 10 лет спустя - ВСЕ СЕРИИ ПОДРЯД
9:04:59
Комедии 2023
Рет қаралды 2,7 МЛН
⬅️🤔➡️
00:31
Celine Dept
Рет қаралды 48 МЛН
Tutorial Part 2   Creating the Drawable for GTA V from Blender
3:21
The GTA V & GTA VI Experience
Рет қаралды 14
How To Make A Health Bar In Unreal Engine 5
15:19
Matt Aspland
Рет қаралды 73 М.
Unreal Engine 5 - How to create a Health, Mana and Stamina bars
59:20
Unreal By Yourself
Рет қаралды 3,7 М.
Learning Unreal Engine in One Month to make a Game!
15:25
Will Hess
Рет қаралды 47 М.
Set Timer By Function Name/Event | Unreal Engine 5 Tutorial
15:52
Tyler Serino
Рет қаралды 11 М.
How to Set up Health and Damage System  - Unreal Engine 5 Tutorial
28:08
Build A Level Transfer System To Spawn At Any Location In Any Level
13:07
I went through ALL Unreal Engine Plugins, here is what I found
36:35
Alat Seru Penolong untuk Mimpi Indah Bayi!
00:31
Let's GLOW! Indonesian
Рет қаралды 7 МЛН