everybody welcome to part 5 of the Time
Attack blueprint tutorial in the last
video we created the save game object
which will hold our best times for the
best overall time and the best lap in
minutes and seconds that's about as far
as we got with our save game so if
you're jumping into this tutorial series
midway through just to learn about save
games you can follow along by creating a
save game object and adding whatever
variables it is you want to save inside
your safe game object okay so let's
start building our save game there are
number of ways you could do this you can
use the game mode to save your variables
to the way I prefer to do it this my
personal preference I like to just
create an actor and drag that in my
level and then in each level I can just
plop that actor in my level and not have
to worry about updating game modes if
they switch or I think some other
tutorials do it to the level blueprint
having to do that each time in the level
blueprint so we're just going to create
a blueprint brand new blueprint call it
an actor and we're gonna call it
BP underscore save game actor head enter
now we're gonna open it up on the
components tab I'm gonna add arrow this
will just allow me to make sure I see it
when I place it inside my level I'm just
gonna save it real quick and before I
forget I'm going to place it into my
level right now so now the save game
actor is in my level and you'll see why
in a moment why I like doing it this way
okay go back to our save game actor and
the graph tab want to add some variables
we're going to add a couple ents so it's
a tint I'm gonna call this B for default
best time SEC it's gonna be uh why is
that a capitalized and I can't change
the damn cat i/o anyway we're gonna this
will be our best time the default time
for our best time in seconds we're gonna
do the same thing
great another in the best time oh my
gosh stopping capitalized time in create
another variable or do you best lap
seconds the only variable the best
minutes I'm gonna create one more
variable and this one's gonna be a save
game object we're gonna go down the
variable type type in save game and we
want the actual save game object we
don't want these two blueprints up here
so in choose save game and then we're
gonna call this BP underscore save game
file save now that I've compiled and
saved I'm gonna set some default values
for these the best time in seconds I
think I'll just leave that at zero and
set the best time in minutes to so it's
two minutes is our best time best lap
we'll set it to 45 seconds and then
we'll also set the best minimum I will
leave that alone actually we'll make it
0 so it's yeah the serial and 45 seconds
now I'm gonna make these and it's a
editable with an editor if I compile
again inside the editor now when I
select my save game actor you see I can
reset I could set these to whatever I
want now if I want to change what my
best times are gonna be the default
value so it's just a lot easier to set
it there
okay back in the savegame
actor blueprint we're going to start
with an event begin play so right-click
event again play and we want to enable
input enable input in this blueprint and
I'll tell you why in a second let's
right-click a player controller now we
want to enable input in this blueprint
because we want to allow the player to
reset these times if they want from
within this blueprint so by enabling
input player can press a button and we
set their time so we're gonna do that
real quick let's just scroll down right
click I'm gonna use the letter R to
reset you use whatever you want I'm just
gonna use our cuz it's easy
preset and what I want to do now is
right click get player controller and
then get I'd and off of our HUD we want
to cast that to our blueprint my HUD
and what I'm doing here I'm gonna drag
off of this and get our race start
variable that's in our HUD and see if
the race has started because I want to
say if the race is started and don't
allow the player to reset the times
while the race is ongoing
we're only gonna allow this if the race
hasn't started so let's hold B and click
for a branch so if the race hasn't
started we're gonna allow the player to
reset their times that's all we need for
this right now we'll come back to this
in a second how they'd all this proceed
add a comment if the race hasn't started
okay
so let's go back up here off of our
enable input but we first need to do is
check and see if a savegame exists so
we're gonna right click type in does
savegame exist look that up and we need
to enter a slot name now the slot name
is created when you first create a save
game or load it and we're going to use
the same one throughout this project so
just to make things simple I'm gonna
type in save game slot hit enter and
then we're gonna hold B branch yeah
we're gonna these up like so now we'll
start on the false portion of it first
it doesn't say if game exists it doesn't
so we need to create one so drag off the
false create the same game object and in
this drop down here we're going to
choose our save game object which has
our for it's in it so we're gonna pick
that and once we've done that we're
going to alt and drag our variable here
in and set that to this so it creates a
save game object and sets it to our
variable here okay now we want to grab
this variable so ctrl to get it and we
want to drag off this cast to our save
game file actor object
let's plug this in and inside of our
savegame we have some port you have four
variables in there those are our saved
best lap min so we want to set that
we're going to set that to our default
value so set best lap men and best sec
probably could have had better naming
conventions but this works for me best
time
we're gonna plug all these in so and we
need to drag in our default values and
assign these to these safes lot so we'll
grab our lap min there our lap second
put it under their time men plug it
under there and time SEC under there so
and now that we have them all hooked up
we need to actually save the game to the
slot so we're gonna right click say game
to slot we're gonna plug that in there
and for the save game object we're
actually going to use our variable that
was created and plug that in like that
and our slot name is the same one that
we assigned back here which is same game
slot so we're gonna call that save save
game slot and once we've saved our game
we need to update our HUD so if the
player presses our to reset the times we
need to tell our HUD to update as well
so we're gonna do that real quick before
we forget so right click get clear
controller get HUD and then cast that
cast to my head
and what we wanted to do is drag off
here and set the HUDs best lap end and
set the hugs best lap second best time
to command you want to set it not get it
then also
let's call these up
so
and then we're going to grab our default
values over here and just copy and paste
those of course I didn't do it in the
same order but I can move them around
yeah did I know I did good job so we
have lap men lap seconds time men and
time seconds and that's what we want to
update our HUD with is the default
values we're gonna plug these in a
little bit cleaner and then I'm going to
create a comment around the U so I don't
remember what this is see updates
that's a compile and save
ok so we have what happens if we don't
have a save game so we need to now do
what happens if we do have a save game
we need to load it so we're gonna
right-click and choose load game from
slot plug that in and our slot name
again is right there save game slot if I
went too fast it's right there it's not
saved okay it's not and we want to grab
our object alt and drag it in plug that
in like so
and then we want to let's move this up a
little bit that's gonna drive me crazy
where is this plug-in right there okay
we're gonna grab our save game object
which is being set here and we want to
again do the same thing cast to you BB
save game and then we want to do what
with this object we're going to get the
best times from our save game and pass
them to our HUD so we need to get player
controller and then cast to my
okay plug that in like that and move
these up just a little bit I'm gonna
cheat since we did this down here I'm
gonna copy my best
all these best lap seconds time seconds
and minutes and copy all those then I'm
just gonna paste them up here not sorry
Hulk all of these up
I'm gonna create a little bit more room
for me here let's just bring this up
just a little bit okay now we need to
form our save game get the save best
time wind so we want to get that kind of
push it up here so it's out of the way
I'm gonna get the best time second so
let's get our nuts that get our best
time second let's move out there then
let's get our best best lap min and get
our best lap sake then let's plug all
those in here so we have best time men
it's gonna be displayed on our ah nope
let's not do that
that's lap sorry our best lap min goes
to our HUD best lap and then our best
lap second we're gonna go to our HUD
best lap second do the same for time so
we're gonna grab our best time then and
our best times second and plug that in
as well what great coming around on this
and say loads times
way
that's just for consistency also add a
comment around this this says resets the
best times to default
okay I think there's one more thing that
we need to do in here chose an IRC game
we've created it and we can load it and
reset it if we need to there's one more
thing we need to do let's go back down
here where we have our button to reset
our HUD what we need to do is split this
up now right-click and add 8 d once and
we're gonna go off the false on this and
we're gonna plug this into our great
save game object so if the race hasn't
started I'm gonna be able to press R the
race hasn't started so other race has
started I'm sorry so we can't do it if
there is hasn't started then we can
create a save game object over our save
game slot here and reset our times
okay I'm gonna compile save go back to
our game here and let's click play and
hopefully this works yeah so you can see
we have our best time we have our best
lap let's see we can drive through we
haven't had any logic put in to
determine what our best times are yet
and that's something we're going to do
in the next video
we still need to set up our lap record
check function and then also check when
all three laps are completed what do we
do at that point and how do we check if
we've beaten our best time so we'll do
that that next video I hope you guys
tune in hope you enjoy