okay now that we have our uh course
generating let's go ahead and add some
obstacles that we can dodge so we're
going to make these a blueprint as well
so we'll go to blueprints right click
add a blueprint
class and actor so we BP we'll call this
BP
blocker and we'll open that up now this
is going to be super simple all we're
going to do is a static mesh and set the
type to be SM Rock so we use this big
rock and I'm just trying to use uh stuff
that's in the starter content so if you
guys want to follow along you'll be able
to use this rock as well so we'll
compile and save that now we're going to
go into our floor tile and we're going
to want to spawn these randomly on our
floor tile but we don't want it to be
completely random we're going to for the
Rocks we're going to use specified
points and for those to represent those
I'm going to put in some Arrow
components and I'm going to call this
spawn
point and I'm going to move it off to
the far end a little bit and maybe up a
few units 30 units or so I'm going to
duplicate
that I'll call this spawn point L for
left and move it over there I'll
duplicate it again and make it spawn
point
R okay so now now we have these arrows
that are going to represent where we
want to spawn our uh rocks so what we're
going need to do is first of all I'm
going to save these locations where
these arrows are into a uh an array so
I'm going to make a quick little
function to do that and I'm just going
to say get spawn points in fact you know
what I'm going to say
set set spawn
points and all I'm going to do is I'm
going to take my components here the
arrows that I just
added and I'm going to get their
relative
transform for each one of these so I'll
just copy
this get your relative transform and
also I'll get a relative transform from
you so I'm going to find out where in
the world relative these these arrows
are let me make sure these are connected
so I'm going to get all three of these
relative transforms and then I'm going
to stick them in an array so to do that
I can just do make
array I'll add some pins and I can start
attaching these and you'll see as I
attach these the color changed to
represent that these are
transforms so now that I have the array
made I want to save this in a variable
so I'll promote it to a variable I'll
call it spawn
points and let's make sure that we get
this guy connected
up okay so now we have this little
little function that's just taking the
arrows finding out where they are and
sticking them in Array so on
construction script I'm just going to
call this right away I want to
immediately create this variable with
these transforms in it so then I'm going
to make another function and I'm going
to call this spawn
blocker and this is going to do the work
of spawning our obstacles so I'm going
to drag off here and the first thing
I'll do do is add a child actor
component now I could just spawn actor
from class again but what I want to do
is as I you know as I set up before I'm
throwing away the floors as we run off
in the distance and if we use a child
actor component it's going to it's going
to be connected to that floor its parent
floor so when that floor gets thrown
away it's going to throw away anything
that's attached to any child actor
that's on it so all the the obstacles
and whatever else we have that goes with
that floor so this way it'll just keep
things cleaner so for the actor class we
use our
blocker and where we want to spawn it
we'll take our spawn points array and
we'll get something from
that and if we go ahead this will
automatically work so well not
automatically we'll go into our
construction script and after we set the
spawn points let's spawn the blocker so
now if we compile we're going to get a
rock on one of our arrows but we don't
want it just on one Arrow we want to
randomly go on one of these three areas
so let's go back to spawn blocker this
is super easy to do we can just drag off
of
here random iner in
range and then get the last
index from our array and we'll go zero
to that last
index so now if we go back here and we
simulate it's going to jump around
different points okay excellent so let's
see how this looks in the game if we
play we're running we're not really
running we're kind of strolling here so
let's quickly jump over to our character
and and make him go a little faster um
so what we're going to do is we're going
to go to my blueprint and we're going to
make sure we show inherited variables so
we can see the variables from our parent
class we'll open up character and select
the character movement and over in
details we'll open that up and we'll go
down to Max walk speed here which now is
600 so even though we're given Max input
every time it's maxing out at 600 so
let's pop this up to say 1,500 that'll
get us running a little bit
faster there we go running fast and as
you may have noticed we are going
through these rocks and that's not what
we want so let's find out why that's
happening and fix it up so we'll go to
our
blocker select our mesh and if we go to
Collision presets we're on block clock
all Dynamic so that's not the issue I'm
betting that this static mesh doesn't
have any Collision on it and it does not
we have Collision showing here and we
have no Collision but we can fix that
real quick and unre engine 4 we'll just
go to Collision hit autoc convex
Collision we'll get this little menu and
I'll just keep it at defaults and hit
apply and there we go now we've got a
little Collision match uh attached to
our mesh so we'll save that close it out
and now we should be able to smack into
these things
boom all right fantastic but that itself
doesn't do anything so let's make it do
something let's make it kill our
character uh so we'll go into our Run
character what I'm going to do is I'm
going to make another custom
event and I'll call this guy death he's
super tiny so let's zoom in here to see
that okay so this is going to be our
death function and when our player dies
we're going to call this and it's going
to be our death routine so normally when
you were setting up game you'd probably
want to have some sort of death
animation or whatever
um since we're prototyping I just want a
visual representation that we're dead so
first thing I'm going to do is I'm going
to disable
input and the next thing like I said I
just want a visual visual representation
so I'm going to spawn
emitter and I'm going to use the P
explosion and man I do demos a lot and
for some reason a player running into
something exploding seems to get a l
laugh everywhere I go I don't know why
so I tend to use that quite a lot for
player death but anyway we'll spawn that
from the actor location and while we're
at it why don't
we play the explosion sound as well and
again hey this is stuff that's in uh the
starter content so you guys can do the
exact same thing or you can get more
fancy and and do something else for your
death um so we'll do that and then let's
take the mesh
and set the
visibility on that to be hidden so
visibility is unchecked so we'll hide
the mesh so when we smack into this our
death routine is going to play some
particles play a sound and hide the mesh
so we're going to need to call this from
our our blocker when we hit it so we'll
go to our
Rock and we'll go down and we'll add an
on component
hit now on this we'll drag off we pass
to our Run character just make sure it's
our player and if it is let's call that
death function make him
die all right so there we go we'll save
that off I don't think we really need to
mess with our blocker anymore so I'm
just going to close him
off so now let's test this out and see
what happens we can run and we hit it
boom all right we have a little problem
here and I know exactly what this is
what we're doing we disabled input
because we don't want to dodge anymore
but if you remember in our movement
input we are telling it to move forward
on tick and that's going to always
happen so let's set a branch
here and we'll make the condition a
variable and I'm going to make this is
dead so if I'm dead I don't want to move
forward anymore so this is now say if
I'm dead is true keep moving forward we
want to change that so I'm going to hold
control and I can reattach this to
false so now if we're dead uh we're
going to check is dead if it's false
we're going to keep moving forward if
it's true we're not going to do
anything and let's make sure that down
in our death
function we go and we set
this to True when we
die so we'll go and set that to true and
let me just check here real quick I'm
going to compile this uh is dead by
default we're true we don't want that we
don't want to be dead by default okay so
we're going to uncheck that um and then
we'll compile and save so now we've got
this checking to make sure that we're
not going to keep trying to move forward
so we should hit the rock and explode
once fantastic so while we're at it for
prototyping purposes we're probably
going to want to test a bunch so let's
set up a reset thing here I'm just going
to throw a delay
in two seconds and then again you would
do something more complex with
restarting your game in a real game but
as a prototype let's just call console
command restart
level so this way we should be able to
play D and it should restart our our
map boom Dead 2 seconds and we restart
with a new stage okay excellent so now
we have a guy running um we've got some
obstacles that we can dodge that come
out randomly and we hit them and we
explode for some reason we're made out
of TNT or something anyway um so let's
uh end the video here in the next video
let's put some good items in that we can
pick up