okay now that we have our player control
setup let's start generating our running
course and as I said we want to make a
course that just keeps generating
endlessly as we go so we're gonna do is
we're gonna make a blueprint that is
basically a floor tile and we're gonna
keep spawning that as we run so let's
start by going to our blueprint folder
and making a new blueprint class and
we'll make that an actor and we'll call
this BP floor tile and we're going to
open that up and the first thing we're
gonna do is we're going to add a scene
component cuz I want to be able to move
around and scale the things below it so
now we can add a bunch of fancy static
meshes but since we're just doing a
prototype here what I'm gonna do is any
is one of the basic shapes that's
included and just add a cube here and
I'll call this floor and I'm gonna
change the scale on it let me get ten by
ten my point one and the original cube
is actually a hundred units in size so
making this ten by ten we now have a
thousand unit floor tile and while we're
at it why don't we just add some I don't
know brick there we go
the scales a little weird but hey it
looks like a floor anyway we'll take
that and we're gonna do next is we're
gonna move this 500 units up on X this
is the direction that we're gonna be
running in and the reason is I want the
origin and the blueprint to be here and
we'll see why in a few moments anyway so
we now have that I'm gonna duplicate it
call it wall change the scale a little
bit make Y point one make z2 or
something move that over minus 500 and
up a little bit now I'll duplicate it
again get wall to and pull it over to
the right side not super fancy but here
we have our little floor tile and we're
going to be able to spawn these in the
world as we run so one more component I
want to add before we move on to
spawning them I'm gonna go in and then
an arrow component and I'm gonna call
this attach point and I'm gonna move
that up a thousand units to the other
edge so basically what I'm gonna do is
this is just a little arrow what I want
to do is I'm gonna spawn one of these
and then after I spawn it I'm gonna use
the position of this to be the place
that I put my next floor tile so what
I'm gonna do is I'm gonna add a little
utility function here and I'm gonna say
get attach transform and all this is
gonna do is it's gonna look at my attach
point I'm gonna get its world transform
and then I'm gonna use that as a return
variable so the type transform and I'll
say attach transform and I'll plug that
right in there so we just get it back so
we'll be able to call this at any point
and find out where in the world that
arrow is and use that as a point to
attach our next floor tile so we'll
compile and say at that and then go back
to the map now next thing we're doing
was we're gonna just do a new level and
we're gonna use the default we don't
need to save what we have now in here
there's a bunch of different ways we
could spawn these tiles when we can make
a new blueprint that is say our course
generator and we can have that generate
other tiles what I'm gonna do is I'm
just gonna use the game mode just
because it's super easy to access and
it's already here so I'm gonna rename
this run game mode and I'm gonna spawn
my tiles from this so I'll open that up
and since this data only we're gonna
need to hit the open fold blueprint
editor and now we can add some script so
the first thing I'm gonna do is we're
gonna add a function and you're gonna
find that I love functions I'm going to
call this add floor tile there are a
bunch of different ways you can organize
your stuff organize your script in
blueprint you can add
you know collapse graphs lots of
different ways you can do it I
personally like functions a lot just
because I don't like to have a long
chain of stuff with a bunch of different
things in it and this way I can just
call a bunch of different functions and
I can kind of see the overview of what
my logic is doing without getting in the
nitty-gritty of what each function
itself is doing so anyway I'm gonna have
a function called add floor tile and
what I'm gonna do is exactly that I'm
gonna spawn an actor from class and the
actor I'm gonna spawn is gonna be my BP
floor tile now we're gonna need to
transform for this so I'm gonna make
this a variable and I'm gonna call it
next let me actually select that next
spawn point and you'll see why in a
minute
so now that we have this little function
I'm gonna go to our event graph I'm
gonna hold P and click and get an event
begin play and when we start playing I'm
immediately gonna add a floor tile now
let's go over and check this out we'll
go ahead and kill the floor that's here
I'll delete that and let's send me like
this
there we go we get a floor tile spawned
in the world now one thing I notice here
real quickly we have our player start
here and when we spawn it's right right
on the edge of that so it probably
better if we have it up there somewhere
so let's move that up about I don't know
200 some units so now that we've played
we're gonna be more on the floor and not
just on the edge there so next what
we're gonna do is we'll go back to our
game mode
we'll go back to our floor tile add
floor tile function I'm gonna drag off
the return value and we're gonna cast to
BP floor tile and after we cast to it
I'm gonna call that function that we
made and which is get attach transform
so it's gonna ask where is that arrow on
you and then what we'll do is we'll
assign that to the next spawn point so
now what we have here is we have a
little function that is gonna take
a transform spawn a tile and then ask
that tile where where do I attach the
next tile and it's gonna save that off
so the next time we get it's called it's
gonna use that point to spawn the next
tile so what we can do here is we can go
back to the event graph where we did
this and we can stick in a for loop now
we can say make this zero to nine and
get obviously ten floors programmers and
their crazy zero base counting so zero
to nine we're gonna have ten floors so
if we go and we simulate this there we
go we've got 10 of these floor tiles in
a row now as I said we want to make an
infinite course and it would be a really
really bad idea to go in here and
somehow make this an infinite loop
because computers just don't like doing
that and they're gonna want to crash and
it's just not good so what we'll do is
we'll set up a system where as we pass
each floor tile we'll tell it to add
more floor tile so let's go to our floor
tile again go to our viewport and we're
gonna add a box collision and we'll call
this and trigger and we're going to move
this off to the end funny enough we'll
change the Y to 500 and the Z to about
200 and we'll move it up a little bit so
that it's a bit higher okay so now we
have this nice little trigger at the end
of our floor we're running from left to
right here so we're gonna set the
collision on this to overlap only pond
and then we'll go in and add a begin
overlap event we'll hit the plus here
and add that so what we'll do it first
we'll check the other actor and we will
cast to our run character let's just do
a little quick check to make sure that
that's our player and if it is we'll get
the game mode this is just our general
game mode well
pass that to our custom run game mode
and then in that custom run game mode
we'll call our ad floor tile function so
we'll add another floor and we don't
want to keep the old floors around so
what we'll do here
ándele say I don't know two seconds for
safety and then we'll destroy actor and
keep that to self so all it's going to
do is when we hit that end trigger it'll
call the game mode and say hey it
spawned on the other floor tile wait a
couple seconds and then destroy
ourselves so if we look at this in the
game we play
then I'm immediately gonna f8 and jump
out and look off in the distance as the
guy runs you can see that we get more
tiles generated in the distance and
behind him
you're gonna also see that the floor
tiles start disappearing and this could
go on and on forever and just keep
running but it's not all that exciting
of a game so in the next video let's
start adding some obstacles and make it
a little bit more exciting