How To Create A Pause Menu - Unreal Engine 4 Tutorial

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hey guys welcome back to another religion 4 tutorial today i'm showing you how to create a pause menu for your game so this will allow you to actually pause the game and then show a menu from which you can resume the game or quit it so without further ado let's get right into it so what we're going to do first is actually create our pause menu widget so to do that i'm going to create a new folder to keep it nice and organized i'm going to just call this pause menu like so open that up and then in here i'm going to right click go to user interface and then widget blueprint i'm going to call this pause menu widget like so just so i know what it is i'm going to open that up straight away now this is where we're going to design what it looks like and also add the button functionalities so what we're going to do is i'm going to have the background so it's blurred so you can kind of see the game but it's a blur and i think so you can focus on the buttons and the menu itself so to do that what we're going to do is get a blur from up at the top left here background blur search around the palette drag and drop it in there i'm just going to set position x to zero position y to zero size x to 1920 size y to 1080 or just basically how big your screen is and i'm going to anchor it to the whole screen there so it doesn't move the z order i'm going to put is -1 so it's going to be behind everything that we want so it doesn't blur anything else and down here under blur strength i'm gonna set this to five obviously you can see there how blurred it is so if you have it it's two be like that or three so i think i'll have it as three for the moment actually obviously mess about this to get the perfect value for you and also you'll be able to see better what it looks like when you actually put it in your game and you can just easily change it from here so next we're going to add the buttons so which compile this and then add the buttons so here you can drag in the buttons no i don't want it that big so i'm just going to drag and drop it onto the canvas panel there you can see that's how big it is i'm just going to scale up to be around that big i reckon and anchor it to the middle so it doesn't move from the position it's supposed to be in so i think that's good so i'll just put it there like that so i think that'll be good for me that positioning i'm just going to call this one resume button as that's what i want it to do so like that the style i might change this so on normal let's say it's white like that on hovered we'll change it to a little bit of gray and then on press so when you press it it's black now you don't need to do this and you can customize this completely differently if you want but i'm just doing this so you know kind of when you're hovering over it when you press it and all that good stuff and we're going to do is drag some text onto this so for the top left here again in the palette drag text place it onto the button this one i'm going to call resume text and then the actual text down here so text block i'm going to put resume like that and here you can change the color the font all of that but i don't really need to want to do anything at the moment but obviously you can you have the options there but i think for me that would be good i'm probably going to change the size which is also on the font you can just drag that up like that to get how big you want it to be so i think 53 would be good for me and what i'm going to do is just simply duplicate this to get our quit button if i just hit ctrl c and select the canvas panel in the hierarchy down here and hit ctrl v then have another one and again line this up to where i want it to be so i think that'll be good and then i'm just going to call this one quit instead of resume and you can add as many buttons you want you can add options credits all this but this is just what i'm using at the moment and how i want it to be and i'm showing you the basic functionality of how to get it all working so i think that looks good for moment and also just add text up at the top up here just to say that it is paused just so you know that it is so i'll do that and again i'll just scale this up actually size content anchor it to the top middle there and i think that'll be good now it's quite big but again you change this to however you want so that looks good design wise now let's add the functionality so if we click on the resume button here so have it selected scroll down on the bottom right to on clicked press that we now have an on clicked event put the resume button so when you click this it's going to fire off this code and then we'll also get one for quick button so here quick button on clicked this one is simple we're just going to get quick game like this and resume we'll do in a minute so we'll set up the functionality to actually pause the game and all that good stuff first and then we'll get back to this one so if we minimize this and go to our player character so we can just select it here edit third person character or whichever character you have all we can do is create a way to pause the game so you can create an action mapping for this but i'm just going to get the escape key so i just get escape like that so when you press escape it will pause the game and that's the most common one but you can change this to whatever you like obviously and we want to have this execute when pause ticked up there which means you can then use escape to unpause the game as well when the game is paused so that's very important to have then what we're going to do is come off of the pressed and get a flip flop like this and off a we're going to create widget like this this widget is going to be our pause menu that we just created so pause menu widget there return value we're going to add to viewport meaning that we then see this and then after this we're going to simply pause game so set game paused i'm going to set this to true so the game is paused and off of b so when you press it again to unpause the menu to unpause the game sorry we're going to come off of b like i say and we're going to remove from parent untick context sensitive like that remove from parent the target of this is going to be the return value of that widget that we just created and what this is going to do is just take this menu this pause menu off of our screen and then we're going to again come out of this set do set game paused but again this time we're gonna leave it to unticked so the game is no longer paused so that would work like this that'll be the functionality for that done so if we just finish off the menu to have the resume button work we come here unclicked drag out set game paused like that what we can do is just leave that unticked like that so the game is no longer paused and also again remove from parent like so so we're unpausing the game and taking this off of our screen so this should work now so if we hit compile minimize and hit play to test this let's see if we hit escape obviously that didn't work that took me out the game because you need to be in standalone game to use that's otherwise escape we'll just remove you out the game so that's my bad so we'll try that again so we're now in our game what i'm going to do is just type in the command set res 1920 by 1080 to make this full screen like that and see if we can move about if we jump press escape the game pauses so we're no longer falling because the game is paused we then have this menu here where it looks all good we've got the blur we've got our two buttons and pause at the top however you can see we don't have our mouse cursor and so that is something else we need to fix which i just forgot about so we'll do that now so to fix that we go back into our pause menu widget here actually third person character here what we're going to do is off the first escape we're going to set show mouse cursor here but on take context sensitive again and type this in so set show mouse cursor there that top one we're going to set this to true and then we'll set this to false again off of this one here set to false if we hit compile we do need the targets and they will just be get player controller like that so that can be plugged into both of those as that target hit compile that now works and so now again we'll get this for the widget as well so when we pause it we'll report the game and show the mouse cursor and then when we unpause it we're not going to show anymore so if we do the same here plug it in there so show mouse cursor to not true when we then unpause the game from here as well this should now work a tree so if we try this again so compile minimize hit play to test save all this obviously and then i'll do the same command to go into full screen obviously you don't need to do it's not necessary but it just looks a lot nicer for testing out so i'll let this load there we go set res 1920 by 1080 we now have full screen we can jump the game is paused we have our mouse caster here again paused if we hit resume we then have resumed the game like so and then if we hit quit the game should close like that so that works perfectly so i'll show you this again as i think that'll be for this video as we've done everything wanted to do we've created our main menu widget and when we press escape the game pauses it shows that widget and it looks great so we have the background blur the buttons and the fonts so the game is paused we've got the background blur it says pause at the top we have our two buttons for resume and quit which the functionality both work and obviously you can customize this however you like and add as much detail into them as you want and obviously escape also works in here as well so we're in here and press escape that works perfectly so thanks so much for watching i hope you enjoyed i found it helpful and if you did make sure to like subscribe down below so thanks so much for watching and see in the next one [Music] you
Info
Channel: Matt Aspland
Views: 48,742
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, menu, paused, game, pause game, quit, resume, how to pause, blur, blurred, background, escape, button, press, toggle, flip flop, ue4 pause menu, main menu, options, ue4 main menu, ue4 menu, ue4 menus, menus, tut, set, mouse, show, cursor, curser, see, cant, can't, make, widget, hud, viewport, add, to, create
Id: Guq7HvYo_Nw
Channel Id: undefined
Length: 8min 45sec (525 seconds)
Published: Sat Sep 19 2020
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.