♪♪♪
(Wes Bunn) All right, so welcome back. In the previous video, we set up all the Components
that we need for our playable Character here inside of our Character Blueprint. We assigned
our Camera. We assigned our Skeletal Mesh for the visual representation of our Character.
We also made some adjustments to our Character Movement settings as well such as the Jump
Z Velocity and Air Control, etc. In this video, we are actually going to start working in
the Event Graph and providing the functionality to handle when input is provided to drive
our Character in game. So we are setting up how the Character actually moves. To do that, inside
of our Character Blueprint here still, we are going to hop to the Event Graph. So
if you have the Character Blueprint up, go ahead and hop to the Event Graph tab. If you
don't have the Character Blueprint up, go ahead and inside your Content Browser just
Double-click the Character Blueprint folder. That should open it up and then hop over to
the Event Graph tab. Now this tab may look similar; you may have some nodes up here that
are kind of grayed out. These nodes are here by default. We are not going to be using any
of these; we are going to use our own. So I am just going to Right-click and drag those
off-screen so that we have a nice big open area to work inside of our graph. Now before
we start adding nodes actually, I wanted to pop up our Input settings that we did a couple
videos ago. Actually, it is probably more than a couple videos ago now, but those Input
settings we did inside of our Project Settings. So if I go back to the Level Editor Viewport
here, under Edit and Project Settings. Down under Engine, there are our Inputs. So these
Action Mappings and Axis Mappings: MoveForward, MoveRight, etc. Let me pop this off really
quickly, like so and bring this up so we can see it. What we are going to be doing is taking
these MoveForward, MoveRight, all of these Axis Mappings, and providing the nodes for
those inside of our Event Graph here so that when these are called when W or S is pressed,
then we can actually provide the functionality to move our Character. So let's go ahead and
do that. I am going to close Project Settings; I just wanted to show that really quickly.
Re-maximize our Blueprint here. The first one that we are actually going to add is the
MoveForward. So go ahead and Right-click in the graph. In the Search bar, go ahead and
search for "MoveForward". Now, you can see we are presented with two options: we have the
Axis Events and then we have Axis Values. The Axis Value will, as the name suggests,
give us the Value of our Axis MoveForward. In essence, how much are we moving, where
are we moving, etc. We actually want MoveForward the Event. So when this Event occurs if you
select it, then we can provide some script to tell the Character how to move off of this wire here.
To do that, first of all let's drag off this wire here. Left-click, drag, and let's
search for "Add Movement Input". There are two options here as well. We want the one under
the Input section here. These are the nodes that provide input from various sources: keyboards,
mouse, etc. Go ahead and select the Add Movement Input node. Once that node is added to the
graph, you can see it is asking for a Target which is our Self. This Blueprint is asking
for a World Direction to face when moving. Then we have the Scale Value, which is the
amount to move. There is also a Force option, which we are not going to be dealing with too much.
It says, "If true always add the input ignoring the result of IsMoveInputIgnored."
We are not going to be using that, so don't worry about that. But we do want to worry
about the World Direction and Scale Value. Fortunately for us, the Scale Value is pretty
easy. All we are going to do is take our Axis Value here and connect that to the Scale Value.
So just Left-click, drag, and connect to the Scale Value like so. So we are getting the value,
the length of our movement and passing the amount to move into our Scale Value. For the World
Direction, we have to do something a little bit different. We need to get the direction
that the Character is facing so that we know which direction to move. To do that, we
are going to Right-click in the graph and we are going to search for "Get Control Rotation".
There is not a g in rotation, I don't think. There we go. Get Control Rotation. You can
see it is under the Pawn setting here, so go ahead and select that.
It is going to give us a rotator here, indicated by this lavender pin here. What we need to do
is actually break that rotation because we only care about one aspect of Rotation.
If you recall, Rotation includes Pitch, Yaw, and Roll. We only really care about the Yaw,
so let's go ahead and break this Rotation. We can do that by dragging off this pin here
and releasing. Down at the very bottom, there is a Break Rot, which is short for Rotation. (Laughter)
Go ahead and select that. You can see it gives us the Pitch, Yaw, and Roll. Like I said,
we only care about this Yaw here. So let's drag off the Yaw and let's make rotation. So Make Rotation
or Make Rot, and go ahead and select that. By default, it is connecting it to the Pitch.
We don't want that, so I am going to hold Ctrl down, drag this wire and plug it into the
Yaw, like so. I am going to move these nodes over a little bit here just by Left-clicking
to select all of them and then just moving them over just a little bit so that we have more
room. The next thing that we need to do is now that we have our Yaw, what we need to
do is Get Forward Vector, the way that we are facing. Let's go ahead and do that
by dragging off the rotator here. Let's search for "Get Forward Vector", like so.
That is going to give us our World Direction. So let's move all this over just a little
bit and connect it. So our MoveForward is set up. We now need
to do the MoveRight Input Axis, so let's go ahead and do that. Let's Right-click and let's search
for "MoveRight". Again, there is the Axis Value and the Axis Event. Be sure to choose the
Axis Event, so MoveRight. Now that we have all of this information here, this process
is actually going to be pretty easy. All we have to do is drag off of this rotator here
and Get Right Vector. So we are going to drag off, release, and search for "Get Right Vector".
Once we have that just like we did up here, we are going to Add Movement Input. So I am
just going to copy this. Ctrl+C and Ctrl+V. Let's plug that into the World Direction,
like so. Let's connect the executable here. Left-click, drag, and plug that into the Add
Movement Input. For the Scale Value just as we did before, let's grab our Axis Value here
and plug that into the Scale Value. So I Mouse Wheeling Down to zoom out a little bit
here; our movement is set up. We still need to account for mouse input, controlling the
camera, as well as jumping. But let's add a comment around this really quickly just
to remember what all this does. I am going to Left-click and drag a selection box around all of these
and hit C to add a comment. I am just going to type in "Movement". This is the Movement script. Okay,
two more things to do. Let's do our mouse input really quickly. So Right-click and drag
our Movement script out of the way so that we have more room. I am going to Right-click
and search for "Turn". Now, that is going to give us a couple options here. We have two Axis
Events now. If you recall, we have Turn and we have TurnRate. The TurnRate we are going
to use for setting up the Gamepad Right Thumbstick gamepad control for controlling the camera.
For our mouse input, we actually want to use our Turn Event. So go ahead and select Turn
Event. Let me Mouse Wheel in a little bit. This is going to be super simple here. All
we have to do for this one is just grab this Axis Value because whatever we are using for
the direct Axis Value from our mouse, whatever we do with the mouse, we want that to control
the camera. So all we have to do is drag off Axis Value, release, and search for "Add Controller
Yaw Input". So that is going to give us direct Left and Right movement on our mouse, like
my cursor is currently moving. So wherever we move our mouse, our camera is going to
follow. Now we need to do the Up and Down, so we are going to get the Pitch for that.
So to do that, let's Right-click and let's search for "LookUp". So again, we have our
LookUp and LookUpRate. LookUpRate we will be using for our Gamepad Right Thumbstick
control. But for the mouse, we are going to use the LookUp Axis Event here. So go ahead
and select that. Just like we did with this above, we are going to drag off the Axis Value
and search for "Add Controller Pitch Input". So go ahead and select that. Now our mouse
control is done. So let's add a comment around these. Left-click, select them all, and hit
C. Then, this is our Mouse Input. Now the last thing that we need to do is add
our jump. So let's go ahead and do that. I am dragging over to the right here just a
little bit. Let's Right-click and search for "Jump". Under Input > Action Events, there is our
Jump that we created. So go ahead and select that. It is giving us a Pressed and
Released. So when the button is pressed, we can do something. We can also do something
when the button is released. We are only going to do Pressed, so let's drag off of the Pressed
pin here. Fortunately for us, this one is going to be super simple. Let's just search
for "Jump". Right there under Pawn under Character, you see there is a function for jumping. Now
this is one of the reasons that we chose to use Character, again, as our Parent Class instead
of Pawn as Characters have the ability to use that Character Movement Component which
includes things like jumping. So this makes it super simple for us. Let's go ahead and
select Jump. You can see Target is a Character and we are done. That is all we need to do
for Jump. So make a quick comment around those. Left-click, drag, and then hit C. This is
"Jump". So there we go. We are actually going to pause now in this video. We have created
our WASD movement. I forgot to mention this actually. The MoveForward and MoveRight Axis
Events here we have set up our inputs to also account for gamepad controls with the Left
Thumbstick and assigned those under our MoveForward and MoveRight. Again, if you want to see that
really quickly let's go to Edit > Project Settings > Input. Again, there is our MoveForward
and we also added our Gamepad Left Thumbstick Y-Axis here. We did that for our X-Axis as well.
These two settings, we don't have to do anything special for these. These are going to come by default
whenever MoveForward and MoveRight is called. We don't have to set up any extra logic for
controlling on keyboard versus thumbsticks. But for our TurnRate, you can see we set those
up a little bit differently. We have TurnRate for our Gamepad Right Thumbstick X-Axis and
LookUp Rate for our Gamepad Right Thumbstick Y-Axis. We used Turn for our mouse control
and LookUp for our mouse control. So those are set up a little bit differently. So the
Left Thumbstick is set up, but we still need to set up the Right Thumbstick. We will do
that in another video here coming up shortly. But that is going to wrap it up for this video.
Back in our Character Blueprint, our Character Movement is set. Our mouse control is set
and we can jump. We will pause here and in the next video, we will set up our Game Mode
which will allow us to assign a default playable Character which we can assign this Blueprint.
Then we will test and we will see if we can run around and jump in game. So let's pause here and
we will pick it up in the next video. Thank you guys for watching and we will see you then.
♪♪♪