Checkpoints made EASY! - Unreal Engine 5 Tutorial

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hey guys um today I want to show you how to create checkpoints for your game and in this case um you run into a checkpoint box you end the game by dying or whatsoever and if you reload the game then you start at the checkpoint location and not at the bass player location again you also have the opportunity to have multiple checkpoints so I use this check I reach this checkpoint load the game again and I start at the other checkpoint okay so let's just start um with the checkpoint we need three blueprints for that we need the player blueprint and we need two new blueprints that we create ourselves so let's just create the blueprints first and then at the end we go into the character do the right click in the content browser and make a new blueprint class we make a new actor this will be our checkpoint blueprint point BP uh then we also want a new blueprint class and there we don't do an actor we do all classes we open up and create a safe game object you just press in save game and there it is save game select call this save game object okay so what we will do is like we will save um we will save the location of the player in the save game object we will trigger the checkpoint and it also set the location of the checkpoint in the checkpoint blueprint you will see what I mean and then we will load the game in the character okay so let's go um we first go in the save game object and there we basically store every data we want therefore we create a new variable here you can create any variable you like and store them in the save game object so let's say player location we can you can write player lock and the player location needs to be a vector so that we have the three coordinates X Y and Z vector compile safe as I mentioned you can create more variables here and save all of them that's it for the save game object so let's jump right into the checkpoint what we need here is we need we just need one component here so we add it by box Collision so this means that as soon as the player get into this box Collision then we will save the location of the actor like of the checkpoint actor himself um and if the player restarts the level then he will spawn at the checkpoint location this is what you have to know so we go to the box we select the Box component scroll right down here and then we do on component begin overlap bam so now we have the the note here on component begin overlap and what we want to do is that so first what you do is we make a check if there is already a checkpoint existing we do this by does save game exist the important thing is there we have the slot name we will create the slot name and this will be actually a file stored in your computer like created in your computer where the all the information from the save game object will be in um let's call this check and it's very important that it's always written check and in exactly that type so you could if you want to make sure you can go with just one you know we will do just one so you will see what I mean so here we ask does the save game exist but we don't really do a true or false so we need a branch here [Music] so here we ask it and here we we say if it's true or false and so let's go with the first um step is like false because we don't have a safe game object yet so we say create save game object very good and there you go if you see we have the save game object here this is the save game object we created the other one is basically the one from unreal so don't worry about this save game object okay there we will do one thing we will now pull out player lock um we will set player lock the thing is if you don't see player lock here you really have to see that you have under safegame object that you have compiled this okay um yeah now what we will do is we created the save game object now we have to save game to slot and the best way is to if we pull out of the blue return value here and we do um save game to slot and here again we need the um we need the one from the slot name this will be the file name on the computer as I mentioned and one thing here is that we really need to execute this node so press Ctrl pull it out here place it in here and boom first one is done okay so now what we will do when there is already save game then we will load game from slot load game from slot and here we also write in one it will always be the same name you can write in a name that you want you can also by the way if you don't want to write in the name all the time you can pull it out promote a variable call this check and then you can call this any name you want basically also again and you can always Pull It in here get put it in there and so on but I won't do this now [Music] okay so here we need um since we loaded the game from slot we need to cast to the save game object cast to save game object and there again we will set the location of the player again oh yeah I forgot something um we'll do this in a moment so um we pull out of the say safe s safe game object into the set player lock again [Music] and also we pull out here and say save game to slot again so um yeah we do the over saving exactly so one thing I I forgot is that we really need to set the player location um to to somewhere and actually we want the location of the checkpoint itself so that the player if if the game reloads that the players start at the location of the checkpoint you understand so what you do is you uh you just press right click and get actor location [Music] and to make sure this is not the location of the player this is the location of the actor himself the checkpoint itself this will place here and here and they go for the checkpoint blueprint this should be it so the last thing we need to do is we um need to create we need to to load when the game loads that we really load the game um yeah in the player you can do this somewhere else but I I I believe in the player it makes the most sense so let's go into the player blueprint you find it under third person blueprint and third person character blueprint this is the player basically so what we will do here is um we will do the same thing as in the checkpoint we will ask at the beginning of the game does save game exist then we will do the branch and if not then we will do nothing but if yes we will load game from slot cast to save game object so these four notes you can basically just copy I will show them again in the other [Music] um blueprint so you can see so we have does save game exist slot name one into the branch and untrue load game from slot slot name one cast to save game object so here we want to ask this does save game exist at begin play [Music] so if the game starts then it will ask does save game exist again if not nothing happens the player will just start at a default location but here's the thing when we load the game um so if if there is a checkpoint saved then we will load the game from slot we will cast to the save game object and we will set I know we will get player lock from the checkpoint so this is the saved player location and this location we will set the player the the location of the player himself to this location so what we will do is that we pull out here of the um of the vertex variable and we do um set player oh no set actor location [Music] set actor location in this in this case it means of the player because we are in the blueprint blueprint of the player we do this we connect the execution pins here and I think that's about it let's let's just try it out it's it's already it should already work so um I placed the checkpoint somewhere you have to see that um oh one thing let's go back into the checkpoint and press on the box here in the components box and then we will turn off the hidden in game it's basically on the right side here on the details panel um hidden in the game off compile save and yeah so we have the checkpoint there and check it out I can even create multiple checkpoints let's see now I start the game I run into my checkpoint okay so there's nothing visual but actually the checkpoint saved let's do Escape and play again he will the game will start now at the checkpoint if I go to the other checkpoint stop the game and start it again I will start at the second checkpoint [Music] um if I get back to the first checkpoint I get also the first checkpoint again so yeah one thing maybe to to improve a bit is um we can we can make a we can make a little um message when we get the checkpoint um when we get the we get to the checkpoint so we do the when the Box overlaps we do a print string [Music] say checkpoint reached [Music] and then not compulsive and then um if I go into the checkpoint you see on the top left corner checkpoint reached and it's always doing it like if I'm if I get into the checkpoint again it's again saving um if I want to have all my checkpoints deleted so for example um I want to start at the base location again and not at the checkpoint there's just one thing to do so let's go into the character blueprint again and we do on input let's say let's say p input P key input Let's see we will find it here the P key you can use whatever key you like we do print string [Music] checkpoint deleted [Music] and yeah it's basically a node called delete game delete game and slot and as you may know there is if you place in the same name as you always did like the one uh just to just to show one thing here if you go into the unreal um folder of your of your project on the saved save games you have now the 1 Point South file which we created basically from this um create safe game and so on so this was the very basic um way of creating a checkpoint if you want uh yeah we can we can create more quality of life uh things for it so setting the rotation and so on maybe changing that the checkpoint is always like that that you can checkpoint get the checkpoint again and again but if you would like to see that please leave a comment anyways if you liked the video please give me a like And subscribe to the to the Channel I want I really want to do more of these tutorials uh also if you if you'd like the if you liked the video consider checking out my game that I'm creating with Unreal Engine it's called Expedition third person platformer yeah you can play it on Steam it's a free demo at the moment and it's uh like 50 done the game so yeah I would love to to get more uh to get more players in for my game okay so see you I hope this helped you and have some nice Game Dev guys bye bye
Info
Channel: Frece Crowhall
Views: 2,985
Rating: undefined out of 5
Keywords:
Id: ZsGOqXjoI8I
Channel Id: undefined
Length: 15min 48sec (948 seconds)
Published: Fri Aug 05 2022
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.