hi there this is Rob from Epic Games
Japan now as many of you know the
blueprint system in Unreal Engine 4 is
really great for adding logic to your
games but it's also fantastic if you've
got that game idea and you just want to
make a quick prototype especially if
you're someone like me it's not relating
programmer so in these videos I'm gonna
make a quick prototype of a game and
show you how I put it together now I did
this a couple weeks ago at a developer
conference and in Osaka and out here in
Japan a lot of people really got a kick
out of it and I also did something
similar about a year ago and there's a
video out there somewhere that's all in
Japanese and the sound quality is
horrible but it got a bunch of views so
I figured there's some interest so I
decided to redo this in English and put
out some videos and hopefully some of
you folks around the rest of the world
can get something out of it as well and
if nothing else hey I get to talk about
Unreal Engine in English which is not
something I get to do a whole lot so
let's jump right into it and first I'll
tell you I had an hour to do this in
Osaka and I was thinking what can I do
so I decided I would do an
endless-runner game so I'm gonna have a
player that just keeps running forward
and you're gonna be able to dodge some
objects dodge some obstacles pick up
some items and the course will keep
generating so just be able to keep
running endlessly and play the gun game
as long as you want now when I first did
this about a year ago I had this
straight flat course and what I decided
to do a little differently this time is
to add a little more variety of the
course and also have some corners where
when you reach them you can turn 90
degrees and go off in another direction
just to give the you know game a little
bit more variety and make it a little
more exciting so let's jump right into
it
and first thing I should mention is we
could do this with a blank game and
start totally from scratch but what I
decided to do was use the third-person
blueprint so from the project mouse or
browser I used the C to much speaking
Japanese anyway third person I use the
third-person blueprint and I include the
starter content and made a project out
of it so the reason for that is just
because you know the templates are great
if you want to make a prototype I mean
here we are I already got a guy that's
running around he's animated
you can jump and the camera moves around
so it's really great easy way to start
without having to you can jump right
into making your game logic and not have
to worry about setting up your character
too much so we're gonna start with that
and the first thing we're gonna do is
we're gonna change some of the controls
on our character so I'm gonna go in here
and I'm gonna change the scale of these
icons just to make it easier for you
guys to see the first thing I want to do
is I'm going to take my third person
character and I'm just gonna rename him
run character is just so that when you
know make it easier to follow when I
whenever I refer to the wrong character
you'll know I'm talking about the player
on our game so we're gonna double click
and open him up and as you can see
there's already some logic in here for
to move this guy around and make him run
around and the first thing I'm gonna do
I'm gonna do this demo all just with
keyboard input so just to make it a
little simpler and easier to understand
I'm just gonna get rid of this gamepad
stuff there's no reason you can't use it
and actually much of it will actually
still work but the touch input I'm gonna
get rid of that too just to simplify
things and make it easier to understand
and the next thing mouse input here
that's you know we're moving the mouse
around it's moving our camera around and
in this game we just want to have a
fixed camera sort of above and behind
the player so we don't need any mouse
input at all so i'm gonna also just
delete that and while we're talking
cameras let's pop over to the viewport
we can see the camera is directly behind
the guy we're gonna put this a little
bit above him and behind him so we can
see a little bit further you know in
front of our character and be able to
dodge things so we're gonna go to the
socket offset here and just add 100 NZ
just put it up a little bit behind him
so there we go so we'll compile that
real quick and then go back to the Matt
graph now let's talk about the movement
input here we have input access from
moveforward and moveright now we're
gonna use this move right to dodge right
and left but for the move forward we're
just gonna have him constantly running
forward so we don't need any input at
all there so I'm also going to delete
that and in its stead I'm going to add a
tick event
so tick on every tank on every frame I'm
just gonna say you know take them
forward vector and move forward so with
the scale value of one that's gonna be
forward direction and he's just gonna
keep running and we can quickly see that
if we want we can jump over to the game
let's back him up a little bit and hit
play and now he's just gonna run for it
I'm not touching any keys but if I hit
right and left I can still move right
and left so that's great that's a great
start and we can go from there so the
next thing I want to add is as I said I
want to have corners in this game and
when I reach a corner I want to be able
to turn 90 degrees and go in either
direction and I'm also gonna have this
just work with the and D keys and it's
really super easy to add inputs for keys
just right click type a and I got a key
event a there type D key event D I'm
gonna add these two quickly so what I
want to do is I want to have you be able
to turn when you reach a corner
so I'm gonna need a condition for that
so I'm going to add a variable and a I'm
gonna call this can turn and it's just
gonna be a boolean ring true or false
either you can or can't
so I'm gonna look at this I'm gonna
control drag it in I'm gonna look at
that and I'm gonna branch off of it
first of all if I can spell branch card
play okay a branch off of that and if I
can turn what I want to do is set a new
rotation that I want so I'm gonna make
another variable and I'm gonna call this
desired rotation I'm typing terribly
today okay and this is gonna be a
rotator so I want to set this when I'm
able to turn and the way I'm gonna set
it is I'm gonna take the rotation that I
had and I'm gonna use a combine which is
basically just adding a rotator and I'm
gonna take the off and say minus 90
because I want to turn minus 90 to the
left when I hit a and that's gonna be
the new rotation that I want for my
character now I can just take all this
dude
it and bring it down to D and the only
change I'll make is because I want to
try and write I'll make that 90 degrees
right okay so now I have this little
setup for my input keys I'm just gonna
comment it out and I'll say and D input
four corners now when I've set these
when I've hit these keys I'm setting a
rotation but I'm gonna need to process
that rotation so I'm gonna come down
here and I'm gonna make a new custom
event and I'm gonna call this turn
corner now in this event what I'm gonna
do is I'm going to take the rotation
that my player has and I'm gonna see if
it is the same as this rotation that I
want so I'm gonna look at the control
rotation which is the rotation of my
character and I'm going to compare it to
the rotation the desired rotation the
rotation that I want and I'm gonna see
if and when they are not equal so if
they're not equal I'm gonna branch off
of that if they're not equal I want to
adjust my rotation so that they become
equal so what I'll do is I'll look at
the player controller and I'm going to
set the control rotation so when they're
not equal I'm going to set that control
rotation and the way I'm gonna set the
control rotation I'm gonna get a little
more screen space here is I'm gonna take
my current control rotation and I'm
gonna interpolate from it so I'm going
to use this our Interpol and I'm
interpolate from that to the desired
rotation and that's what I'm gonna use
as my new rotation and we're gonna need
to Delta here so I'm just gonna add some
Delta Delta world Delta seconds and say
for interrupts speed let's do five okay
so we've got this set up to do that
processing what we're gonna do is we're
going to stick it in our tick tick we're
going to check and see if our rotation
is what we want it to be
and if not then we will adjust it so
we'll put our turn corner in there so
normally it's not gonna do anything
because our desired rotation is gonna be
set it's not until we have one of those
curves that we're going to be able to
turn we're gonna get a new rotation set
then it's going to start interpolating
to that new rotation but let's go ahead
and check test this out real quick so to
test it out I'm gonna set the scale of
the forward movement to zero so just you
won't move and then I'm gonna take my
can turn and I'm gonna make it default
to true so we'll be able to turn any
time we want so if we play now when I
hit D it's gonna rotate to the left or
right I'm gonna hit a he's gonna rotate
to the left so that's exactly what okay
so let's go back in and I did notice it
was a little slow so let me go to the
interim speed and say put it up to ten I
check that real quick guess we just just
want a quick little turn okay so I'm
gonna put our run speed back up to one
or one or scale value back up with one
and our can turn I'm gonna make it
default to no to false okay
so here we have our player control
pretty much set up so we'll just go
ahead and comment this real quick I'll
say do corner turn and let's now that we
have this set up let's do a quick
prototyping test let's just see if this
is going to work the way we expect it to
so we're gonna go in here and I'm gonna
drop in a box trigger and I'm gonna go
in and scale that up a little bit and
move it up in the world and I'm gonna
set it hidden in game to false so I can
see it then I'm going to take my player
and I'm gonna make him run straight into
that
so now we're gonna set up some logic on
this trigger we're gonna go into the
blueprint level blueprint I'm gonna
right-click add an event at a collision
edit begin overlap so when we overlap
that box
first I'm gonna do is cast to my run
character see if that's my player and if
it is I'm gonna set that can turn
boolean that we have to true so this is
gonna act as a little you can turn zone
a turning zone so that'll be my corners
when we start making the actual course
so before we get there we should be able
to dodge right and left when we get in
there wish you about to turn 90 degrees
so let's see if that works and Dodge we
hit it we can turn 90 degrees so that's
exactly what we wanted and you can see
we're still able to turn 90 degrees
which is not good so what we need to do
is go back in here and after we've hit
the a key let's make sure that we set
our can turn back to false for both of
these okay so that should fix that so
now we should be able to just turn once
and then we're back to dodging great
fantastic so there we got our player set
up in the next video let's start
building our course