Unreal Engine 5 - How to create a Health, Mana and Stamina bars

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
good afternoon everyone today we're going to see how to implement belt mana and stamina so the first one is alt so if i go here in my collagen box you can see that the l is going down and as soon as i'm going out of that collision box the health is going back up the mana if i press f on my keyboard is going to cast an explosion and if i don't have 20 it's going to display on the screen not enough man and as soon as i can get 20 i can cast again the stamina is a little bit the same so i can run pressing shift and it's going down and same thing if i jump it's taking some stamina so i'll show you exactly how i've done all of that well the first thing that we have to do now is creating a project so i'm going to create the third person project i'm going to call that alt system i'm going to include the starter pack and i'm going to create the project when i'm done in the project here the first thing i'm gonna do i'm gonna create my usual my stuff and i'm gonna put everything i'm creating in that folder so we're gonna go to the third person blueprint and we're gonna open the third person template here what we're gonna do we're gonna do all the logic for health stamina and the mana everything that you saw earlier at the intro will be managed by the third person character so the first thing i'm gonna do here i'm just gonna search on the top here for an arrow i'm gonna implement an arrow and i'm gonna call that magic spanner so basically that's where i want my spell to appear on the screen so i'm going to go to the viewport here and make sure i have magic selected and i'm just going to move that a little bit away from the character you place it wherever you want it's just for the tutorial i place it right here so you can see the explosion right in front of the character we're going to go back to the event graph here so we're going to have to create a lot of variable to do all of that so the first thing we're going to do here we're going to create a variable i'm going to click on the plus here and i'm going to call this alt and i'm going to change the type for a float here and i want to start with you know 10 out so i'm going to start with 10 health and compile and save that so now we're going to create another one this time i'm going to call that max max elt and the max out would be under it so to change the value you have to compile first i'm going to put 100. and i'm gonna put those two in the same folder or the same category so i'm just gonna put alt and i'm gonna put that in out so they're gonna go under the same thing here so now i'm going to create another one now it's going to be for the mana so i'm going to call that mana and i'm going to call create another one i'm going to call that max mana so the mana same i'm going to start with 10 and the max mana would be 100 and both of them i'm going to put that in a folder called mana so like this so they go all under the same so it's a little bit easier when you search and we're gonna do now the stamina so we're gonna call that stamina and i'm gonna create another one and i'm gonna call that max stamina same as usual with compile and we're gonna start with 10 and our max stamina will be on red and same again the stamina will go under stamina and the max stamina will go with it so it's all nice and organized so here in the stamina here we're going to use that for the sprint so we're going to add another variable and this one we're going to call that show drain and we're going to change the type for boolean and i'm going to create another one and we're going to call that this one we're going to call it is sprinting like this both of it are disabled so they're not through at the beginning i'm going to compile that and save that now here i'm just going to find some empty space and we're going to start by doing the uh logic so we're going to right click and we're going to search for event any damage so with this here what we're going to do well first from that we're going to celt set alt so we're going to type alt and we're going to make set and from the damage here we're just going to drag from it do a minus for subtraction and we're going to take our out and we're going to plug our out right here so we're going to get out so i'm just going to move that around like this and i'm going to plug this right up here so basically what he's doing every time we get the damage it's going to set our out but it's going to withdraw the amount of damage from our current out and it's going to set that new out so the bottom here we're going to create how we get back our elk so we're going to create a custom event so we're going to search for custom evid and we're going to call this regain whoops regain elk like so from that we're gonna drag and we're gonna search for branch from that branch here we're just going to drag and we're going to search for equal take this one here from that what we want well we want our elt and we want the max out so we're going to drive from false here and we're going to set our alt so we're going to search for alt and i'm going to set out from that here we're gonna drag down and we're gonna search for clamp i'm gonna take this one here and from that we're gonna connect our alt so we're going to get alt air and our max l that we're going to connect directly in max here and on top here alt what we're going to do here well we want to add some alt so we're going to do add and we're going to connect this to the value here so basically what we're doing is that when this gets called it's going to check if our elt is equal to max elt if it's not equal so it's going to go to false it's going to set our out by adding the number that we want to add so in this case here i'm going to put one and the clamp here is just to make sure it's not go below zero and not going above or max l which is hundred that you can see here so now from that we're gonna drag and we're gonna call for delay and we're gonna put one second here so we're just gonna put oops we're gonna put one and what we do from that well we're gonna get we're gonna call back again that function so basically we call this function it's going to check that we have enough health that it's not equal i mean to the max l if it's not well we're going to go to false here so it's gonna implement plus one to our l and it's gonna set our new value and it's gonna wait one second and it's gonna recall that function and go back again and again until we reach hundred if we reach under it well now those two will be the same so it's going to go to true and we do nothing so we'll that function will stop by itself now we're all done with this so i'm just going to select everything press c for putting a comment i'm just going to call that regen alt logic now we're going to create the mana logic so the first thing we have to do is setting up the key to cast our spell so we're gonna go to edit we're gonna do project setting and we're just gonna go down and go to the input and we're gonna add an action mapping just gonna put that down and you click on the plus here to add your action mapping so i'm gonna call that interac i'm gonna actually i'm just gonna call that spell and when you press here you can select which key you want so i want f to cast my spell so um we can close this we're all done so from here now we're gonna search for our spell that we just created so we have our input here for spell so from that we're going to drag and search for a branch from this we're going to put greater or equal and we're going to connect our speed to it so now from um from false what what we're gonna do we're gonna create a widget so just create widget we don't have the widget yet but it's here we're going to put our widget not enough mana so we're going to add that widget to the viewport so we're going to add to viewport like this i'm going to make sure we connect the target to the return value and i'm going to put a delay so let's put the delay here and i'm going to put two so it's gonna wait two seconds so our um widget will stick two seconds on the screen before disappearing so to make it disappear well we have to remove from parent you won't find it if you do it like this so what you have to do you have just to click here and now you can search for remove whoops remove i don't know how to spell i get remove from parent like here perfect let's just plug those two together so we're all done with the false part so we're gonna drag from the true from the branch and we're gonna set our mana so we're gonna search mana i'm gonna set our mana like this from this um we're gonna spawn not panel but spawn an emitter and we're going to spawn the emitter at location i'm going to send it you see like whatever you want just for the tutorial i'm going to take the same here so i'm going to take the smoke where i want this emitter to spawn well i want it to spawn where we created our magic spanner so i'm just going to drag the magic spanner here and i'm just going to plug this to the location so it won't work because the first thing that we have to do let's make sure that we get our wall location get the world location i'm gonna take this one here now we'll be able to plug that to the location like this so we're all done for that here so from the mana here we're gonna drag down i'm gonna search for clamp i'm gonna take the one with the float and from the value we're gonna drag down and search for uh subtraction so we're gonna take subtraction what we want to subtract well we want to subtract a certain amount of um we want to subtract a certain amount of mana that we take to cast our spell so in this case here i'm going to put 20 like the video and i'm going to take the mana and put the minute right up here and the max here will be our max man like this so what it's doing basically for us here there's a mistake here there's an error because we don't have the widget blueprint uh done yet so what is doing for us every time we press our f key it's going to make sure that our mana i'm going to make sure that our mana oh i forgot to put a number here so it's 20 so i'm going to put 26. so every time we press f is going to verify that our mana it's not below 20. if it's not below 20 well we're going to go forward so we're going to set our mana and it's going to remove 20 from our max man and it's going to cast our spell here so the emitter that we decided to create if we don't have enough mana it's going to go to false and it's going to create the widget that's going to say not enough mana to the screen it's going to add it to our screen obviously and two seconds later it's going to remove it so if we don't have 20 mana we will never be able to go to true so we're just gonna compile that and save so now we're done with that so i'm just gonna select everything i'm gonna do a comment and i'm gonna call that the mana logic area so now down here we're just going to do our logic to regain mana so we're gonna create a custom custom event and i'm gonna call that regain map so from that i'm gonna drag same i'm gonna search for branch and we're gonna verify that it's equal so we're gonna search for equal here that are mana it's equal to or max man so if it's equal to our max mana we're gonna do nothing if it's not equal to our max mana it's mean that we need mana so what we're gonna do we're gonna go from false here we're gonna drag and we're gonna search for our mana so we're just gonna type mana we're gonna go and set our mana from that here we're gonna go search for clamp we're gonna take the float and we're gonna subtract i mean that's abstract we're gonna had so we're just gonna search for add and we're gonna take our mana we're going to plug that right here and we're going to add the amount that you want to add so i want to add 1 in this case and we're going to plug our max mana right here and we're gonna wait so we're gonna do a delay and we'll just have to wait the amount of time that we want before it's casting that again just for me here i'm gonna put three so it's gonna wait 0.3 seconds and after that we're just going to recall the same function so we're going to call mana so we're going to rejainment so we're going to call that again and it's going to add one so basically if our mana is not equal to our max mana it's mean that we need mana so it's going to go to the false here and it's going to add 1 plus 1 to r mana from the total of our mass which is 100 it's not going to go below zero or above 100 so we're good with that is why we use the clamp float it's going to set that new value it's going to wait 0.3 seconds and it's going to recall that same function so it's going to go back up here and redo that until the mana and max mana or equal so if there are equal it's mean that it's true so we won't have to do anything so we're just gonna take all of that i'm gonna do a comment and we're just gonna call that regen mana logic so from that here we're all good for the mana logic and the el logic so we just have to just print but before doing this uh we're just going to create the widget here for uh fixing that error in our third person character so what we're gonna do here i'm just gonna go to my stuff and right click and i'm gonna search for user interface and i'm just gonna create a widget blueprint i'm gonna do a user i'm going to call that would your blueprint underscore not nf mana i'm going to go right in it i'm going to search here for canvas panel i'm going to add that here and from the canvas panel well we just want to add a text i'm gonna add the text right here i'm gonna take that text and put that around the middle here i'm gonna make sure it's size to content and i'm gonna anchor that to the middle of the screen i want that to be a little bit bigger so i'm just gonna change the font of it so something around this i'm just gonna remove that around the middle something like this and we're going to change the text in it so we're going to put nut in a manner so it's going to display that for us i'm just going to recenter that right here perfect so now i just want that to look a little bit better so i'm just going to go down here i'm going to search for the outline and i'm just going to put 5 so it's going to do that black line around it so it's just a little bit sharper and you can change the color that you want so for the case i'm going to put red because red it's always a bad thing usually so we're going to create i mean press ok so now we have our widget created which is going to compile and save so we're going to go back to our third person character and here now we can select or not enough mana i'm gonna take that come apart and save it's fixing our error here we're gonna create uh the sprint so we're just gonna um first we have to go to edit to put our key so project setting i'm gonna go back down here input i'm gonna add an action mapping and i'm gonna call this one a sprint and i'm gonna select shift you can select whatever you want and all set for that so here we're gonna search for our sprint from sprint here we're going to search for branch and from that branch here we're going to search for less or equal and we're going to plug our stamina in it so we're gonna take stamina and we're gonna plug that right up here and we're gonna put a value of one like so well so when we release the key here we're just gonna go by release first so i'm just gonna move that a little bit out of the way so when we release the key here what we want to do well we want to uh set our walk speed back to normal because we're not gonna sprint anymore so how to do that well we're gonna take here the character movement from that we're gonna search for walt uh max speed and we're gonna take this one here so not this one i mean uh this one here i'm just gonna plug that to the release key here from that here we're gonna drag i mean we can just go here and we're gonna put is printing and we're gonna put right show drain right down here from that we're gonna set our max stamina so like this and we're gonna call our regain stamina so uh the regained stamina but it's not done yet so we're just gonna leave that empty but here we're gonna put uh to call another function to basically regain our stamina so here when we press what we want to do well when we press we want to put is sprinting to true so we got to make sure that this is check and we want to change our max walk speed so same again we're going to take a character movement here i'm going to search for wall max speed and we're going to set our max walk speed like this and you put the value that you want so in my case here i'm just going to double uh the original value so the original value it's 600 so i'm gonna put 12 and i'm just make sure that here when we release it's going back to 600 and not zero from that here now we're just gonna put our show drain so obviously we want our mana to to drain so we have to check this box and from here what we want to do well we want to call again our function here so this one it's not created yet but we want to call our drain function and here we're gonna call our regen function so we're gonna leave that as is for now because we have to create the two other but we're gonna come back to this so i'm just gonna take that and put a comment and i'm going to call that that sprint mechanic compile and save that on the bottom here we're going to search for a custom event i'm going to add a custom event i'm going to rename that drain stamina so now as i said here we are joining our stamina it's being done on the top here we're gonna be able to call that function so we're just gonna drive from that and search for drain stamina like so so here on the drain stamina we're gonna drag from it and search for branch just gonna zoom here and from that what we want to do well when it's draining what we want to to check we want to check if it's show drain so we're gonna connect that to here and from that true here we're gonna set our stamina so we're gonna search for stamina we're gonna set that value and same as we did a little bit earlier we're gonna search for the clamp here and we're gonna subtract a certain amount so we're gonna search for subtraction subtraction and we want to remove what for my case here i want to remove one so i'm gonna change the value to one and i'm gonna put my stamina right here our max stamina will go here in max so as before it won't go below zero and it won't go above uh hundred so from that here we're just gonna drag and search for equal equal we're gonna take this one here and from the um set stamina we're going to drag and search for a branch from that branch here we're going to connect this here so if it's true we're gonna put our show drain so we're gonna search for that show drain and we're gonna make sure it's unchecked we're gonna set our max walk speed before doing that we have to make sure that we take the character movement here i'm gonna take that here drag from that walk well max speed we're gonna take this one here plug that into and we're gonna put that back to normal which is 600 so from the falls here i'm going to drag and do a delay i'm going to put a delay of 0.1 seconds and i'm going to call back drain stamina i'm going to compile and say that so basically what it's doing for us so when we call this function it's gonna make sure that show drain is checked so how shall drainage check your wall is from the top here that we did when we press shift so when it's checked it's gonna go to our stamina here and it's gonna remove one point from our stamina bar from our maximum which is hundred from that other branch here the equal so if it's equal it's mean that it's true so if it's true it will no longer drain and it's going to put back or normal speed if it's not true is go to false so it's mean that we have to do a delay of 0.1 seconds recall that same function so when we call that same function it's going to continue to remove stamina until we are equal to this value here so go back to our normal speed so we're just gonna save that i mean we're just gonna take all of that put a comment and i'm just gonna call that the drain logic from [Music] i mean like this here we're just gonna create a custom event once again this is the last step and we're going to call that regain stamina regen stamina i mean so from that we're going to search for branch from the branch here we're gonna check the condition show drain so we're gonna take show drain and plug that right here so we're going to do another branch we're going to put the false to that branch here from the condition here well we want our stamina so we're going to get stamina we're going to our max stamina and we want to verify that it's equal equal so we're going to derive from that press equal and plug those two in and put that right up here so from the true we're not going to do anything so from the falls here we're gonna set our stamina so we can just take our stamina here set from false here we're gonna search for clamp once again i'm gonna take the float here and we're gonna add so plus and we're gonna put in plus we're gonna put our stamina and our max stamina will go to the bottom here like this so from that we're going to search for delete and i'm going to put a delay of 0.1 and i'm going to recall that function which is regain regen stamp i'm going to take all of that and put a comment regain logic regain stamina logic so what it's doing for us well it's going to verify that show drain is um isn't enable if it is uh was going to go to this branch here and this branch is very firing that or stamina or max l or equal if they're not equal it's mean that or stamina it's below hundred so it's mean that it's false so what it's gonna do well it's gonna go there and had a certain amount for us so i want to add one so every point one second is gonna add one to my stamina until i'm at hundred if i'm at hundred it's mean that this it's equal so it's going to go to true so it's mean that we're not going to do anything so it's going to be done so i can compile and save that so now we just have to go up to our us print logic here and what we want here well one will release the key we want to gain back our mana right or stamina so from that here we're just gonna search for the stamina and we're gonna call here or stamina that we just did so just to recap everything so when we press print here if we are uh minus i mean minus less than one uh it's mean that if we're not less than one or equal it's mean that we are allowed to sprint so what he's doing is putting our value here um sprint to true it's gonna set our max speed to 1200 it's gonna drain our stamina so when we release well it's pulling back our speed to normal it's removing the value i mean the false or true from is spurting in children and setting our stamina and we call back or regain a stamina so here the max stamina i just see that we have to put 100 here because it's or max stamina or you can just you know take max stamina and plug it right here like this so now uh what we're gonna do we're just gonna do the user interface so we can see that on the screen now we're gonna create our widget blueprint that's gonna display the l the mana and the stamina on the screen so right click user interface with your blueprint user widget and i'm just gonna call that widget blueprint underscore hud i'm gonna open it when i'm in it here i'm going to search for canvas panel i'm going to put it down here and from that we're going to search for a progress bar program progress i'm going to drag that on the canvas panel that progress bar well i'm going to rename that alt bar and i want my alt bar to be red so i'm going to change the tint here under fill image to be red there you go and i'm going to anchor that to the bottom left corner so i'm just going to move that down here like this and from this bar here so you can adjust the size that you want so i'm just going to put that like this so now we're just going to duplicate this bar i mean the color didn't accept so here we go now it's going to be red so now i'm just going to duplicate that two times this one would be called the mana bar and i'm gonna move that up here [Music] obviously you adjust the way you want and i want the color to be blue and this one would be the stamina bar i'm gonna move that up here and i want this one to be green compile that and save that so now i'm just gonna add text here so i'm gonna search for text i'm gonna put that between just under held bar i'm gonna do that for the mana and the stamina so this would be called alt because it's the text you can leave the the top here whatever but i want to change here the name so i don't want text blocks display on the screen so i'm going to put alt i'm going to check the other one and call that mana and take the other one here and call that stamina so now i'm just gonna go up here and i'm gonna move my text move one text here one text here and one text here i'm not gonna put the l right here and put the stamina down here and a minute right here obviously now you can just play to adjust that the way you want so i'm not going to spend too much time on that obviously and you can just make sure that each of them in size to content so it's fitting perfectly in the box like so compile and save now if you want you can add an image like i had in my display so how to do that well just search for image and you add an image to your canvas panel and you take your image here you drag that down and you size it the size that you want and now you can just add the image that you want to this here in your option you can put the your image so if you click on it you go go to brush here and it's here that you're gonna add the image that you want uh do i have some image here not really it's not too much here it's just a i'm just gonna put that area so it's how you had an image so you can set up that the way you want so it's just gonna compile and save that now from the progress bar we're going to do the little logic that's going to make that bar going up and down so click on your alt bar and we're going to go to progress here when you're going to create a binding so in the binding here i'm just going to make a little bit of space like this and what i'm going to do here i will just um rename this to match what i have so it was the l bar so i'm just going to click on that and i'm just going to rename that like here i'm just going to i don't like to see the percentage so it's just at the bar like this well from that we're going to cast to our third person character from that we have to get the player the controller but the player character and from the third person character well we want our l so we're gonna get health i'm gonna divide that by hundred there we go and i'm going to plug that right here i just want to divide it because um this is point you know 1 2 3 and i want a number that is one two um hundred so one two hundred because this is just going to zero to one right um so i'm gonna compile and save that i'm gonna repeat uh the same process whoops i can close that i'm gonna repeat the same process to um the mana one so i'm gonna click on mana i'm gonna create a binding i'm gonna move that away and i'm gonna rename that so rename i'm just gonna remove this we're gonna do exactly the same so we're gonna cast to our third person character we're gonna get our player a character and from that well we want mana so get mana same thing we're gonna divide that by 100 and we're going to plug it right here compile and save i'm going to go back here designer tab we're going to do the same thing with the stamina so create a binding and move that away i'm going to rename that and i'm going to cast once again to the third person corrector the object will be a player character and from that we're going to search for stamina get stamina we're going to do same thing again divide that by 100 and plug it right there save perfect so now we have our progress bar in the corner so we're going to go back to our third person character so everything is set up for us the only thing we have to set up it's um the even begin play because we want the hud to appear on the screen obviously so what we're gonna do here so we're just gonna search for even begin play from that we're gonna create a widget i'm gonna select the add widget we're gonna add that widget to uh the viewport so add to viewport like this and as soon as the game start i want regen my health to regain i mean regain health i want to regain my math and i want to regain regain my stamina like so perfect and compile and save that so let's see if it's work so now here we can see that the alt mana and stamina are working so i press f it's saying not enough mana so i know exactly why it's doing that so if i do sprint the sprint doesn't work as well so i know exactly why it's not working so we're just gonna go back and fix that quick so go back to our third person character and we're gonna go to the spell one first and i put less here we need greater so we're gonna put greater or equal so we want greater or equal 20 and we're going to go to the sprint mechanic here same thing i put less here we need greater so we're going to search for greater or equal i'm going to plug that here and we want number one in it so we're going to compile and save so if we try again now so let's say not enough mana because i'm not at 20 yet as soon as i reach 20 i can cast and stamina if i run the stamina is going down perfect so we're all good for that so we're gonna have to just check our help now we're gonna create the collision box so blueprint class actor i'm gonna call that bp underscore collision box and i'm gonna open it when i'm in it i'm gonna search for a collision box and i'm just gonna resize the collision box so it's a little bit bigger i'm gonna compile and say we're gonna go to the event graph we're not gonna use the event tick and the actor beginning overlap we're just gonna go from the um even begin play so from the even begin play here we're gonna create we're gonna search for spam emitter and i'm gonna take attach and we're gonna attach that to our collision box so it's gonna spawn where our collection box is from the collision box here we're gonna right click add event begin overlap and move that down here and i'm gonna do the same thing again but for the end overlap so from the other actor we're gonna search for third person character just ctrl c ctrl v i'm gonna do the same thing here for the n overlap like this so from this one here well i wrote a reference to my character so instead of casting again i'm just gonna promote this to a variable and i'm just going to call that ref here obviously you could put that up here but i'm just putting it here it doesn't really matter too much from this here i'm going to search for timer i'm going to take a timer by event so this one here and from a timer here by even i'm just going to promote this to a variable and i'm just going to call that ref oops ref timer now i'm going to create not create but create a custom event so just search for custom event i'm just gonna call that damage i'm gonna connect damage to the event here i'm gonna put one and i'm gonna make that loop from this i'm going to drag and i'm going to search for apply apply damage and where i want to apply damage to well i want to apply damage to our third person characters we're going to take the reference or third person corrector and plug it right here so now this it's done so from the end overlap i'm just going to move that down here well i want to make sure that when i'm out of that collagen box i don't receive any further damage so from the third person character what i'm going to do well i'm going to search for the regent health because i want to make sure that i get back some health and i want to clear the timer so clear and invalid timer and i'm going to take the timer as a reference plug that here and compile and save so basically what it's doing for us here when our character will step in the collision box is going to set a timer and the timer will call the damage event and it's going to apply damage to our character when we step out of the box it's going to call the regen function that we did in a third person character to get back our else and it's going to clear the timer so it's going to disactivate this so we won't receive further damage so we're going to compile and save go back to the third person character so i'm just going to add the collision box on the floor here and i'm going to do play i think i put it a little bit too low so put that here go back to the collagen box i'm just gonna click here on the box here and search for hidden so i can see it while i'm in game so i'm just gonna uncheck this so i can see the box now so the box is right there so if i walk in it i don't receive any damage so i'm gonna make sure that we get some damage so we're gonna go back here to the collision box here and we're gonna make sure that we apply damage i want to receive 10 damage so we're going to try that again as you can see the l just went down i have no more else if i wait the l is going back up if i if i go back again the l is disappearing so you have your out the mana and the sprint is working i can see that the collision box here has something that doesn't work here there we go so we're gonna select a good one here so i do play here we go now the smoke is working so now we just have to add the numbers on the bottom back in the widget add we gonna add the number here so we're gonna add text i'm gonna put our text right here and i'm gonna put just gonna change that to 100 i'm just going to align that here i'm going to make sure it's size to content and i'm just going to duplicate that two times so i'm going to put that just under out and i'm going to duplicate that again i'm just going to put that under mana so now there are the top here so i'm just going to move that down there we go so this one is held this one is stamina so i'm just gonna move it to stamina i'm gonna call this one for elt and i'm gonna take the other one for mana i'm gonna line that a little bit so down the number over there so we're gonna click on this one here and i'm gonna create a binding so we can um add the logic to have the number change so we're gonna here on text content we're gonna binding when i create binding just gonna move that out of the way i'm gonna rename that binding here i'm gonna get l number so from that here we want a reference to our third person character so we don't have any at this time so we're just gonna go to the uh event graph and we're gonna do a reference with so at uneven uh construct here i'm gonna drag and cast to our third person character this one here i'm gonna make sure that i get the player character and i'm gonna promote this to a variable and i'm just going to rename that ref there we go so back to we're going to go back to our this one here get out number now we can cast your third person character so we're gonna take not cast but we can get our reference from this we want obviously we want our alt so we're going to search for elf i'm going to get out i'm going to drag again from it and we want our max elf so we're going to get max lt like this and from that here we're just gonna drag and search for format text and here in the box we're gonna create those little thing i think call that cone but i'm not too too sure so you click out you close it you put a slash and you open it again and you put max alt and you close it so now it's going to create those two uh pin here so we can connect alt and max we're going to compile and save and just try if it's work if we go back you can see that we have the number that go up so it's exactly what we want do we get damage if we go in the box well the box is not there so i'm gonna add the box so just go back here add collision box here we go so now the box is there so if i go in it the num the numbers are going down obviously it's going to minus because i didn't set up dead that animation so we can see that the number is working so we're going to do exactly the same for the mana and else i'm just going to go back in our ad here so we're gonna do exactly the same so i'm just gonna copy paste this because i don't want to redo it i'm gonna go back to the designer and i'm gonna click on the mana i'm gonna create a binding i'm going to rename this binding magnet number like this i'm gonna move that out of the way and i'm gonna copy paste the text here i'm gonna change that for a minute and i'm gonna change that for minute and we're gonna take our reference and we're going to search for get mana in or max mana open up this one get max minute i'm going gonna plug that right there compile and save we'll make sure the return the result is connected to the return value compile i'm gonna try that too you can see we have number now for our mana which is perfect and when we cast the mana is going down i can't cast because i don't have 20. as soon as i get 20 i can cast again and you can see here that there's a little problem not enough it's not going out of the screen so we're gonna have to fix that but first we're gonna check the stamina so we're gonna go back and we're gonna go to the designer click on the stamina create another binding and move that out of the way i'm going to rename this stamina step i don't know what to write apparently and i'm gonna do the same so i'm just gonna connect this here i'm gonna put stamina i'm gonna write the same thing in that box get our reference to our character and i'm gonna search for 10 minute get stamina in or max stamina plug that right there perfect compile and save now we're going to try it we have the number is going up when i run it's going down perfect that's awesome so we can cast our spell so not enough mana and it is appearing from the screen so i don't know why earlier it was not doing it but now it's working so i'm bellow 20 and it's working perfect that's awesome now we have the jump animation but we don't uh we don't use stamina when we jump so we're going to do that as well while we're here we're gonna go back to our third person character and i'm gonna go to the jump animation here not the jump animation but the jump logic in the game which is gonna zoom out here we're gonna have jump here i'm just gonna extend the jump here and stop jumping well we don't need this one here so perfect so which is gonna keep the action for jumping from the release we're gonna call for a delay and we're gonna wait 1.5 seconds and we're going to call our regen stamina from the jump here we're going to do a branch old b on your keyboard so he's doing a branch and we're going to go and search for greater or equal and we're gonna take our stamina put it right here and we're gonna put one you can change your number here um i'm gonna put i don't want to be able to jump if i don't have 10 so i'm going to put 10 so i won't be able to spam the jump key all the time so from true here we're going to set our stamina so set stamina i'm gonna plug the two together like this and from here we're gonna do a little logic again so we're gonna do a clamp float and the value here well we want to do a minus so subtract we want to subtract how much well every time we jump i want to subtract 10 we're gonna take our stamina put that right there and take our max stamina put it right here so now it's sure all work for us let's try it up go back so if i jump i can see there is mana going down however you can spam the key and it your numbers are not going up so we're just going to fix that too so what we need from that well we need another branch so i'm just going to move that out of the way i'm going to do another branch by holding b so from that we're gonna search is falling there we go like this so if him if the character is falling i don't want to be uh able to jump again so here basically when i press if it's greater than 10 i can jump if it's true and i'm going to connect that to true and if him if i'm falling if i true down falling i i want to go there if i'm not falling i mean if i'm not falling i want to go there if i'm falling i don't want to go there so from fall compile and save let's try it up there we go now it's working so you can spam the key and your stamina is not going down if you're have the good amount so that's perfect so everything is working so that's perfect it's exactly what i wanted to show you so as you can see now everything is working the damage bug is working so when you go in it health is going down with the numbers you can cast your magic you cannot cast if you don't have 20 and you can run your stamina is going down and when you jump the stamina is going down as well so you have everything that you need here so maybe one last thing here you can just change the amount that you want to regain right you can change this or the speed so your delay is the speed that you're gonna cast for regen your l mana or stamina so you can change this or you can change this for the amount for your game so hopefully everything was good for you guys and it's working properly so i'll catch you the next one see ya you
Info
Channel: Unreal By Yourself
Views: 3,856
Rating: undefined out of 5
Keywords: ue4, unreal engine 4, unreal engine, tutorial, ue4 tutorial, unreal engine 4 tutorial, how to, games design, ue5, unreal engine 5, unreal engine 5 tutorial, ue5 tutorial, ue5 health bar, unreal engine health bar, unreal health bar, health bar, progress bar, show health, max health, beginner, Stamina bar, Mana bar, ue5 stamina system, ue5 stamina bar, unreal engine stamina system, unreal engine stamina bar, unreal engine stamina, show stamina, Unreal by yourself, unreal 5
Id: ISQ5yp56A9Q
Channel Id: undefined
Length: 59min 20sec (3560 seconds)
Published: Mon Jul 11 2022
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.