 Hello there team welcome back to Game Dev Academy. I'm Shane Please let me know that you have arrived at this class by writing something down below And if you do that successfully and even tell me which of the houses you're in I will display your name on screen Just like this In the last video we set up our heads up display so that we can have points and lives on screen But they're currently static and they don't do a lot So in this video, we're going to make it so that the lives counter actually shows how many lives we set in the game So by the time we're done, it'll set whatever we tell it to which is what we want in it So let's get stuck in and make it happen make dreams happen Last time we set up the heads up display which you can see I still got open here, but it doesn't do anything yet It's very static so this video is going to be about getting the lives set up And we're also going to create a reset game action as well Which is what's going to set our Elements and the heads up display back to kind of defaults and that's actually where we'll start in this video We're going to create the reset event first of all We're going to do that in the game mode. I've already got that open from last time And we still need to be in the event graph for it and the first thing I'll do is create a new custom event And I'm going to call that Good name. We also need some new variables to track things like how many lives we've got So I'm going to add a variable and I'm going to call this one max lives So this is the maximum number of lives that we can have which is what will be the default when the game resets And you can see by default it's a boolean which is of no use to us We're going to set it to an integer which can be whole numbers And then to be able to use this you can see at the moment There's nothing displayed for this variable. We'll compile it And then we've got an option to set what we want the max number of lives to be I want it to be three So you should then get four lives in total you'll start with one One bolt of fire and then that will replenish three more times We don't need to create one more variable And this is going to be lives So this is how many lives the player has So that's already coming in as an integer, which is good And we'll just compile that so that we can do things with it So the first one we're going to want to do when we reset the game is set the current lives To whatever number so we're going to get this in drag it in and we're going to set it So when we reset the game We're going to set the lives to get max lives So the first thing we're going to do is set the lives to whatever the max lives variable is Which at the moment is set to three Now what we're going to do is move back to the heads up display so we can work on the functionality And in the last step we just worked in this designer Part of the heads up display screen There's also a graph part where you can add some functionality and that's what we're going to explore now So let's give it a little click there and the one that we want is event construct So when this is created so we can delete the tick event And we'll also delete pre constructs. We don't need that right now But it is this event construct that we're going to start with One of the first things that we're going to need to do Is get this heads up display talking to the game mode the game modes holding all the information about how many lives And what the score is going to be so the first thing we'll do is get casting to that and we'll set We'll promote it to a variable so that we can talk back and forth whenever we want So out of event construct we're going to cast to game mode and it's Bio game mode is the one that we created the breakout game mode And here just to make sure we get the game mode. We're going to go get game mode. There it is So the first thing we're doing upon creating this heads up display Is making it so that it can talk to the game mode and then as game mode We're going to promote to variable when I call the variable Game mode so we know what it is And then I'll comment all this with just get game mode so I know what it's doing So now that we can talk back and forth between I just need to compile that Now that we can talk back and forth between the hood and the game mode We can start doing things with that so back into designer for a sec And remember we said that we're setting up lives at the moment So we're going to get this lives text box and I'm leaving that out one deliberately for now and I'm selecting the text box for the number of lives So I've just got it from down here because it's a bit messy up here So just click on that one there and then we're going to create a binding to some functionality. So here we've got bind So give that a click and we're going to create a binding And then this opens up a new little scripting window a widget blueprint for us And in here we're going to need a variable called lives. So let's create a variable lives Lovely this variable needs to be an integer as well. So let's change that to an integer And then so that we've got access to it We need to compile and then we can actually use it in in our script So what we're going to do now is drag this in and we're going to get lives And then out of here we're going to create a two text node and what's going to be an integer And that's going to go into our return node Like so and then we're going to compile there and save as well And then we need to go back into the game mode to get these talking to each other So what we need to do now is to get the heads up display And from here we need to set Lives and that's the The lives that we just created in the heads up display So what we're going to do then is connect this up So that that's going to execute so whenever the game resets It'll set the lives to the max lives and also set that on the Heads up display as well. So that's what's going to display And that will be Magnificent So we're going to compile and save and now's a good time to test But we're not expecting it to work and I will tell you why so let's just click on play You see the lives is currently set to zero It should be setting it to three And the reason that this is not working is because we've not yet got anything Making the game reset and this only happens when the custom event reset happens. So just for now We're going to call this event over here So that this actually works and this is happening on begin play So now we'll compile save and test again And now that's working. It's showing that we have three lives So in the game mode, it is setting that the player has three lives And it's also displaying that the player has three lives And that's everything that we needed to achieve in this step If you're feeling confident you could have a go at setting up the score yourself It's going to be a very similar process But if you're not feeling so confident, don't worry because that's what's coming up in the next step So I will see you there for that I believe that quality education should be available to everybody And for that reason all of the classes at game dev academy are completely free And we're supported by our very generous school governors over at patreon If you'd like to become a game dev academy governor and support our work As well as helping us to steer the channel in the right direction Then use the link in the description to be taken to the patreon page