How To Make A Game Over Screen - Unreal Engine 4 Tutorial

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hey guys welcome back to another engine 4 tutorial in today's video i'm going to be showing you how to do a game over screen in this example would be when you die but you can do this in any circumstance you want this is just when your game ends you'll get the screen so i'll show you what this is going to look like now so obviously you can just play your game and then i've got it so when i press k you die when you die it's going to give you this game over screen in which you can retry where you can quit the game and the quit can either obviously quit or it can go back to the main menu if you'd like that and this can also pause the game if you want or it doesn't have to it doesn't matter also show you these buttons obviously retry if i die again quit closes so again i'll show you how to do that now so the first step is we're going to open up our character blueprint so for me this is the third person character or this be first but whatever you've named it or in your level blueprint so essentially where you have the code for your player dying or where you want the game to end so it could be at the end of a timer so you're doing a level blueprint but essentially where you have that code open that blueprint up right now so let's say i'm going to be doing it when you press the k button it dies i'm going to get a k keyboard event like that and again this is just representative of the code for killing the player so player dead or gay men's code so again this just represents how your game ends so it could be a timer or the player dying anything like that so off of this what we're going to do is we're going to create a widget like this and this is going to be our game over which it will create in a minute at the return value we're going to add to viewport like so then we're going to drag out this again and set show mouse cursor and we'll have to untick context sensitive to get show mouse cursor there i'm going to take that to true and so this way we can use the different buttons that we'll have the target will be get player controller and obviously we'll need to retake context sensitive get player controller like that and then here we're going to do a set game paused and we'll just tick that to true this doesn't have to be here if you don't want it so you don't have to pause the game if you don't want but that's just the option there and then we'll drag out this and destroy actor as this is how i want the player to die so obviously if you haven't got the player dying here or you already have that set up you don't need the destroy actor so essentially this is the main part of the code here for actually setting up this menu so off this code here is where the game ends so you could die you create the widget add it to the viewport show the mouse cursor and pause the game and then this for me is just because this is where i'm killing the player so what we'll do is we'll minimize that before compiling it we'll right click in the content browser use interface and widget blueprint and we're going to create our game over screen so i'll just name it game over widget like so and open that up straight away and for me this is just going to be a very simple base look so what i'm going to do is just get a background blur in here like so i'll set its position to 0 0 size 1920 by 1080 put it z-order to -1 so i put it behind everything i'll just put the blur strength up to let's say 25 seems good and then on top of this so back on the canvas panel i'm just going to put in some buttons so i'll just get a button there like that and then another button i'll move these just down here where i want them i'll rename this top one here to retry or play again whatever you want to name it like so and this one i will call quit or main menu just whatever you want it to do or you can have two different buttons for quite a main menu as well so actually i will do that so quits and this one is main menu and again move that down here so then what i'm going to do is just rescale these so resize these up a little bit and anchor them into the middle and the anchor point is basically where you want this to stay so it won't move from this position so if you have the anchor at the top left the button will be dragged up to the top left along with it so i will just make these so you can just duplicate them when you've already got the size but i already have them in here so i'm just going to be making these buttons but when i get back to actually making any mechanics of them i'll get back to you so again make sure that you have all these anchors set correctly and i think that part will be good for me as i just want the three basic buttons and then i'll move them all down a bit actually like so and now let's get some text on here so we know what they are so up in the top left here i'm just going to drag some text and then put it on these buttons in the hierarchy down here like so and that way the text just stays on the button and works perfectly again i'm just going to rename these to be the appropriate names so i know what they are so i'll call this one retry text and the text box in here i'll just simply put retry or play again or anything along those lines i'll increase the font a little bit just so the size is a bit bigger and then i'll also change it to black just so i can see it and then i'll do the same with all of these again so this one i'll put as quit and so i will write quit in here as well again do the same process so this part is just about creating this to make it look good for us and what we want it to be like and then finally i will do main menu and do all this again like that and again increase the size and then i'll also just get one final piece of text up here i'll do size to content so it says the same and this is just going to be like the title you could call it i'll just write game over in here just so the player knows what's happened and why they're getting their screen that's what i'm going to do here is just give this a small outline instead of changing the color just so it stands out a little bit better like that and again make sure to anchor it up to the top middle here or just wherever you have it so now that's the base look of our game over screen done so that's what we want it to look like now we want to actually create the functionality of this as well so to do that it's very simple we just want to select this retry button here we'll scroll down on the bottom right and get an unclicked button event like so we'll come out of this and we'll open a level like this and the level name is just the name of the level you want to open so it's essentially restarting the game so this needs to be spelt the exact same so for me this is third person example map so just get the name of your level and put that in there making sure to spell it the exact same and then what i'm also going to do is just set show mouse cursor again untick context sensitive and for target get player controller this way it's because we set it to show and now we're setting it to not show to leave it false like that so that is how do you retry now if we select the quit button again on clicked event come out of this and we can just simply quit game it's that simple to be able to quit and if we get the main menu on clicked and we drag out of this what we can do is remove from parents so what it's going to do is take this game over widget off of our screen and then we'll create a new widget this one would be our main menu but i don't really have one at the moment as i haven't made it but obviously this is what you would do and then obviously again add to viewport like so and it's that simple so again i'm going to get rid of this part as i don't have it and that will break my code but that's just because i don't have the screen that would work normally for you so that is it done so if we go back to where we created this code initially we can then input this widget in here so game over widget compile and save this is now done so we can play this to test it you can move around again your code will then run for your game over so when you die if the time runs out anything like that so for me that's k so what it's done is we've got this widget here now you see that doesn't work properly and that is because in the widget itself i didn't actually set an anchor for this background blur so i made that whole screen there as you saw it went to the top left and that's where the anchor was we try again also if we jump you see i'm not falling as the game is paused we've got this widget here the background is blurred it says game over we have retry quit and main menu and we have our mouse cursor to click on these as well if i hit retry the game is restarted like so if i do that again i hit quit the game has quit now if i do it again i hit main menu that took that off my screen as that's all i've got the moment so that will open your main menu and so also actually for that if you actually have a main menu in a different level all you do is simply just open level and then write in your main menu level name there and that will be that part done so again that's it working perfectly so i think that bit for this video we've done everything want to do we've created our game over widget screen so it looks like this for when your game ends we have this screen here in which we can retry quit or go to the main menu and it works perfectly and looks great like this so thanks so much for watching i hope you enjoyed and i hope you found it helpful and if you did make sure to like subscribe down below so thanks so much for watching and i'll see you in the next one
Info
Channel: Matt Aspland
Views: 41,945
Rating: undefined out of 5
Keywords: ue4, unreal engine 4, unreal engine, tutorial, ue4 tutorial, unreal engine 4 tutorial, how to make a game, how to, 3d modelling, blender, unity, games design, graphic designer, ue5, unreal engine 5, pause, game, over, screen, widget, ui, user interface, blueprint, blueprints, game over, game over screen, dead, death, die, when, you, the player, player, dies, timer, out of time, ran, at the end of the game, end, of, the, score, high score, quit, main menu, return, retry, play again, play, try, again, to the
Id: EjH-i-NoYAk
Channel Id: undefined
Length: 8min 51sec (531 seconds)
Published: Fri Oct 30 2020
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.