Welcome back.
So we've seen that if we create a new slot and we select it and press play, we'll load in to the default
player start.
However, if we press play and select a slot that's already been saved and choose that and try to play
it, we don't go into that default player start.
We just go to wherever because we don't have a player start our game instance doesn't have that player
start tag set and it's the game mode who finds the first player start and we go to that one, not this
one in this level, this is our load screen map, but you get the idea.
Now, the reason for that is because when we press the new slot button, we're creating a new slot and
setting the game instance player start tag based on our aura game mode.
Default player start tag.
But when we already have a slot and we're loading it in, we're not pressing new slot button, we're
pressing select slot button pressed, and if we press the play button, that's when we travel to the
map.
So at least some point before we travel to the map, we need to load in some kind of player start tag
that we save.
And if we never actually save one, well, there won't be one to load in.
So what we should do is we should add a player start tag to our load slot.
And that way when we save our data for the first time, that player start tag will be saved to disk.
So our load slot needs it and our save game object class needs it.
So let's go to load slot first and it's going to now get an F name for the default player start.
This is going to be up here with our public variables.
So we're going to make a F name.
And we'll call this player start tag.
And this will get a uproperty.
And in addition to this, our save game object needs it.
Our load screen save game is going to get an Fname now.
So this will be F name and this will be our player start tag.
Now something about f names.
You should never have spaces in them or you can cause some problems, so keep that in mind.
That's why I like to use f strings whenever I have any kind of descriptive text.
F names can't have spaces in them that can cause issues.
But anyway, we have a player start tag and our load screen save game.
And in our load screen view model, whenever we create a new slot, we should set our load slots player
start tag.
We'll set it equal to the default player start tag on the game mode.
So we'll just go ahead and do that here and load slots of slot.
We'll set its player start tag equal to the Or game mode player start tag the default one.
And then in or a game mode.
When we save our slot data, we can go into save slot data.
And make sure that we also save that player start tag.
So load screen save game player start tag.
We'll save that as well to whatever our player start tag is on the load slot.
Now that we're saving it to disk, we can load it from disk as well.
So back to our load screen.
We can take a look at what happens when we click on select slot button.
Either that or when we click on play.
Really it only matters when we click on play because that's when we're about to travel.
So if we're about to travel to a new map, we need to know the player start specifically, our game
instance should know the player start.
So as soon as the play button has been pressed, I'm going to get our you ora game instance called or
a game instance.
I'm going to cast to that and I'm going to call get game instance from our game mode.
So I'm going to actually put this right here just underneath our Ora game mode.
So I can call Ora game mode get game instance.
Now that I have the game instance, I'm going to take our A game instance.
And set its player start tag, because our selected slot has its player start tag set by this point.
So now play button pressed is getting that player start tag.
But when we load data, we have to make sure that that player start tag is set on our slots.
So down here in load data where we're loading everything into our slots, our status, player name,
even the map name we need to load in our player start tag as well.
So I'm going to take our load slot dot value here and set the player start tag.
And we're going to get that from our save object.
So save object player start tag.
Now that we're loading from disk our player start tag whenever we load it.
Then when we press play then we know that our slot that we're getting our player start tag from should
have a valid slot.
So with that change, we can go ahead and close out of the editor and restart.
All right, we're back in the editor, and I'm going to go back to our load menu and press play.
And I need to delete these again because they don't have player start tags saved.
So I'm going to create a new slot.
I'm just going to use S for the name.
And if we select the slot and press play we'll go to the correct player start.
And that's great.
But if we go back to the load menu, press play and select that slot and press play again.
Once again we go to the correct player start because we're actually loading it in from disk.
And now we have the concept of our player start tag saved.
And we can use this to our advantage if we want to save our progress as we're going through different
dungeons, when we reach a checkpoint, for example, we can save that checkpoint for our player start
and this can be really useful.
Now this is the design I'm choosing for this project to have checkpoints and load in at player starts,
but you really could load in your location from disk if you wanted to save your location.
It doesn't have to be at a player start.
That's just the implementation I'm choosing to implement for this project.
I like to use player starts as checkpoints.
Now this is great, but checkpoints should look like checkpoints in the game.
If you reach something that looks like a checkpoint, that's going to tell you, hey, I'm saving my
progress there.
And if we look in our assets and go to dungeon, there's a folder called checkpoint and we have a static
mesh called checkpoint, and this looks like a pretty good checkpoint.
We're going to use this as our checkpoint player start.
And that'll allow us to save progress.
Every time we reach one of these, we know that we've reached a checkpoint.
Maybe we can inform the player that it's reached a checkpoint, and then we can save that player, start
tag and load in at that next time we load in.
So we're going to do that next.
I'll see you soon.