How to Make a Simple Health System in Unreal Engine 5

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
what's up guys welcome to new unreal engine 5 tutorial and today we will be making a simple health system into your player or character and enemies so it's going to be very flexible so you can expand it later but we're going to make the simple core of it and and by the end you have a health bar with a health system so let's get started so first of all let's open our third person blueprint character and what we are going to do is create a new variable okay it's gonna be called health and we are gonna set it to be a float okay so what we're gonna do is quickly go ahead and just drag this in here and we're gonna uh set the health okay so we are gonna go ahead and uh call this function which is event any damage so basically you can call this event from all the places so for example i have made a tutorial on how to make an enemy ai so in your case uh you basically go when the enemy is attacking you will call this event which is apply damage and the actor will be here the player and you will set a damage and then in here uh basically uh in the in the player when we you know sent that uh events from the enemy uh it will reach out to this one and say hey we have received some damage so basically this will trigger when we have received damage so um basically what we're going to do is set the health but first of all let's compile real quick and then go into the health variable and we're going to set a default value for the health in my case i'm going to be the typical 100. so i'm going to just drag the health here and say get and then i'm gonna subtract it okay and i'm gonna subtract health from the damage that we received um from when we uh called um our damage event and then that's going to be the new health great after that i'm going to make a thing and it's going to be a branch so in here i'm going to ask if the health is less or equal than zero so i'm just going to drag again our health direct this and say um less equal here it is okay so if it's the health is less or equal than zero so true that means that we basically need to be that so in our case i'm just gonna go ahead and print that okay and if not well we will go ahead and print our uh actual health so we can you know see how much health we have uh left now in order to do this real quick i'm gonna say that if i press for example m so m key find it right here so press i'm gonna say apply flight damage so this is just an example normally you would call this like i said uh before from your enemy or whatever but uh i'm just gonna make it so you can you guys will uh see what i'm mentioning so i'm just gonna say that our damage actor will be ourselves and the uh damage that we will be receiving is gonna be 10. literally you just need to fill these two uh variables um the other parameters you don't really need to touch them use the damaged actor of course on the damage that you want to uh return to them so literally if now i compile and save and go ahead and press m you can see up there in the left upper corner on the screen you can see how my health decreases and then that i'm dead okay so let's go ahead and quickly make a slider uh to be able to see this better so um and ui and i also made a video stamina if you want to check it out so just uh right click user interface widget blueprint okay user widget it's gonna be our uh there and we p uh health okay so let's go ahead and open it it up you know place it in here um for some reason i don't know why in real gm5 a canvas it it isn't grading by itself so i'm just gonna go ahead and drag this in here so drag a canvas and then you will get a progress bar just drag it on here i'm just gonna kind of place it on here and down here and then the color on here i'm just going to go ahead and place it to be like a a um a dark or actually really bright red okay then in here in percent is where we are gonna you know control this so what we have to do is go here into bind and then create binding and in here what we're going to do is in the get present we're going to say cast to bp third person character so we're going to get our character reference this is going to be get player uh character to be able to find the instance and then on our third person character we are going to get the health so this is going to be current health and enable to display correctly we have to divide this value by our maximum health which in this case like i said before is a hundred so it's gonna be a hundred and then that's gonna be a return value so now we compile and save go back into a third person character i wanted to get our event back in play because we need to add this uh widget into our screen so just drag this say create a widget and then what we have to do i just go ahead and select class and that's gonna be uh wii p health get onan player is gonna be get player controller and then in the return value just add to viewport so there we go we compound save and press play you can see our health bar uh in the button on the screen which is full but if i started pressing m you can see how it starts decreasing and then we are dead and that's it guys if you enjoyed the video please subscribe like and check out my other animal engineering factors comment what are the tutorials you want to see and it's also if you want to see this implemented into the actual enemy ai please uh let me know in the comment section below with all that said bye [Music] you
Info
Channel: Gorka Games
Views: 52,793
Rating: undefined out of 5
Keywords: games, videojuegos, unreal engine, unreal engine 5, ue5, health system, tutorial, quixel, megascans, unreal engine tutorial, how to make a health system, ue5 how to make a health system, ue5 how to make simple health system, unreal engine health system system, unreal engine 5 how to make a simple health system system, unreal engine 5 health system, unreal engine health system, unreal engine 5 easy health system, unreal engine 5 how to make a health system, ue5 health system
Id: kZVIa2uWOiM
Channel Id: undefined
Length: 7min 21sec (441 seconds)
Published: Sun Jul 17 2022
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.