Unreal Engine Save Game Tutorial

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hello and welcome to the tutorial in this tutorial I want to show you how I can create these multiply save games so when we create a new game we can create a character and review it play we go to our first level we can walk around and when we save the game it saves the player position the character itself and our inventory of course you can easily extend the system so let's go first of all the character editor and the inventory system are already in this project of course links in description they are not necessary for the save game but shows the potential of the concept let's start up with the save game object so right click group and class and search for the save game object this one here let's call this game save open this up this is very similar to the game instance so we will start up with the player underscore position the player position is of course on transform the second one is the level itself the level itself is on string and just to show the potential again I add up the character with our character structure and our inventory with our item structure as an array so we can close this one here again right click open class and now we need a game instance this one here I already created one so this is the instance called my instance with our inventory the Hotbar and the character already so we have to add up the player underscore position as well again as a transform be sure that you go to your project settings maps and modes and add up your instant that you created on the game instance class inside our game instance we create and custom event called save game from save game we say does save game exist go from the slot name here remote to variable we can keep it like this one of course we need a branch to ask on true we want to load game from slots and connect our slot name here on false we of course want to create a save game object be sure that you select the game save object that you created then we get the player Pawn we get the actor transform up here we want to cast to our game save that we created we want to set the player position like this one here down here as well like that after this we get the current level name again from the ask game save we want to set the level name and just connect it to the return value here again from the game save we want to set our character like that we get the character from the game instance and set it to the game save we take out the inventory here go from the game instance again and want to set the inventory and as you can see we can do this with every variable that we want to save of course we have to copy and paste this down here as well and just connect the return value with the targets here then at the end we go again from the ask game save and want to save game 2 slot connect it here down here as well and we just connect the return value to the save game we get our slot name again and this will be of course the slot name of course we need another custom event called load game we take out our slot name here we want to load a game from slot like this one then we cars to our game save that we created the first thing is we want to get our level name because we want to open the level by name and just connect our level name here we get the player position then we want to set it to the player position of the game instance here of course we take out our character as well so get character as well we can get our inventory and then of course we want to set it to the character of the game instance as well as the inventory and as you can see it's pretty easy to extend the system here then we need a little delay here of 0.2 seconds we get our player Pawn again and want to set the actor transform and set it to the player position compound save this so we are done here we have our save game function and the load game function we can close this one the last step is of course a menu where we can actually load our save games for this we need some widgets so right click use interface widget I already created one so let's start up with the lower screen one as you can see it's just a border at the background we have four buttons that has a text with new game let's go to the graph here the first thing that we need is an custom event called load game saves we need um sequence with four situations for four safe cramp Slots of course you can create more if you want the first thing is does save game exist and we just type in game save one of course we need the branch to ask then we take out the save text one we want to set the text here on true and we will set it to save game one then we just copy and paste this four times like that and we will just connect it here and we have to edit these two game save two game save three and four and of course we have to replace the save text one with the save text two up here the save text three and of course the save text 4. and this will be save game two three and four let's open up the details of the save button 1 on click to three and four let's put these together here like that we need again and thus save game exists go from the slot name and say promote to variable here put this down here then we want to set the slot name in all situations when we click on a button like that and inside here of course we just copy and paste again the game save names and have to edit this one to game save one game save two game save three and four all of these can connect to the does save game exist like this one then we get the game instance we want to cast to our instance like this one then we want to set our slot name of the instance to the slot name of the widget we need to range to ask if our save game exists then we go from the instance and want to load our game on true on false we want to open a level in this case my character editor it's just the editor so we are done here as well let's go to our main widget let's keep it simple so we just have the start game button and an exit button with the text let's go to the graph and call our start game on click and the exit as well the exit is of course pretty easy we just have the quit game function here on start game we want to create and widget in this case the load screen widget then we call our custom event the load game saves we want to remove the widget from the parent in this case our main widget then we can add up the widget so the load screen widget to the viewport compile and save this let's go back to our level here I already placed these camera actor inside the world let's go to the details I set the auto active for player to player zero so this is the active Pawn where we start the game also I choose this level here as a main menu of course you can choose whatever you want let's go to the level blueprint we need to begin play then we want to create a widget in this case the main widget we get the player controller we set the show mouse cursor to true and then we just add it to the viewport let's open up our third person character because we need a button where we can save the game let's keep it simple and put this on H for example then we get our game instance we cost to our instance that we created and then we just call the save game function compound save this let's see if this works we hit play we have the start game we have our game save slots here we choose new game let's create a character here we hit play we can walk around we can pick up for example this flower here we press e you can see it has the flower we press h for game save where we go back and hit play again we should say start game we have our save game one here we load it the character is on the same position has the same clothing and we have our flower great so I hope you enjoyed the tutorial if you have any questions please let me know and yeah goodbye
Info
Channel: Seredias
Views: 9,536
Rating: undefined out of 5
Keywords:
Id: KTMZl8VJzcI
Channel Id: undefined
Length: 11min 37sec (697 seconds)
Published: Sun Jul 23 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.