Welcome back.
Now that we have our character and our enemies, we need to be able to move them around.
This means we need to be able to handle input specifically for Aura.
We're going to deal with the Aura character first.
And in order to move or around in the level, we need to handle input.
And the way to do that is to set up enhanced input for our character.
So we're going to do that.
I have a lot of windows open here, so what I'm going to do is hover over each of the tabs and simply
click the Middle Mouse button to close those.
So closing all of these down.
Now we've got that under control and we can set up enhanced input.
Now for movement, we're going to need an input action.
So in my content drawer in Blueprints, I'm going to create a new folder called Input.
And here in input, I'm going to make yet another folder called Input Actions.
And all of our input actions will go into this folder for this project.
Now an input action is required for enhanced input in order to take input from some sort of device such
as the keyboard.
So for movement, we're going to make a new input action by right clicking, going to input and selecting
input action.
And the convention is to put in a for input action and we'll call this one move.
Now I'm going to open up a move and the only thing I really want to change here is the value type,
because for movement, I want to be able to handle two dimensional movement.
Left and right is the first dimension forward and backward is the second dimension.
So I'm going to change this value type to access 2D vector 2D that's going to allow me to take input
in the form of a two dimensional vector with two axes X and y.
I'd like to consider X to be left and right and Y to be forward and backward.
Now, let's not get confused.
Here in three dimensional space, we typically consider an actor's forward vector to be the x axis for
that actor.
But for movement, we're talking about a 2D axis space.
Look at the Wasd keys on your keyboard.
W and X will be forward and backward.
We're going to consider that to be the Y axis in this 2D space.
A and D will be left and right.
We'll consider that the x axis in this 2D space.
So now that we have an input action, the way that we link this to our character is going to be through
an input mapping context and that's where we can associate keyboard keys with our input action to move.
So back in our input folder, I'm going to go back up one level.
We'll put our input mapping context right here.
So I'm going to right click, go to input and select input mapping context, and I'll call this emcee
for input mapping, context or context.
And I'll go ahead and open this up.
And here we have our mappings, an empty array currently, but if I click plus I can add one and open
the dropdown and select an input action.
Opening this up, I see that the only one available is the one I just made I a move.
I'll select that Now that we have a move in this input mapping context, we need to associate it with
various forms of input.
Now, for the time being, I'm just going to set up Wasd movement at this stage in the course.
So what I'll do is I'll click on the keyboard icon here and then press D.
We'll start with the D key.
The key is perhaps the most simple.
When we press D, we want to move to the right.
Now I'd like to add additional keys to this, so I'm going to press the plus icon next to move and get
another mapping.
I'm going to click the keyboard icon and press A now pressing D moves us to the right.
Pressing A is going to move us to the left, which means further down the line in our code, when we
set up the ability to respond to user input, we're going to access data that we retrieve as a result
of these mappings and pressing D and A will both result in us retrieving data.
But when I press A, I'd like that data to be negative.
I want to receive a positive one when I'm pressing D and negative one when I'm pressing A and in order
to do that I have to modify that input using a modifier.
So under a I'm going to click plus for the modifiers and for this modifier, I'll open the dropdown
and choose negate.
If I open that index, I see that it's going to negate all three axes, but D and A are just going to
be on the x axis.
And remember, a move is a two dimensional input action with two axes.
So the Z axis here has no meaning for us in any of our modifiers.
For I a move but D and A those are going into the x axis.
Remember I said A and D is left and right.
We're considering that the x axis in this two dimensional space for I a move.
So we're going to negate that x axis.
We don't need Y or Z checked, we just want to negate the x axis here.
So that takes care of D and A, but we want to move forward and backward as well.
So I'm going to click Plus to add another key, click the keyboard.
Icon and press W and this will be for moving forward.
Now, we don't want to negate it.
When I press w, I want to receive a positive one value.
However, I don't want to receive it on the x axis.
In the two dimensional space for I a move I want to receive a positive one in the y axis.
For that reason I have to add a modifier that will force the W key to provide input data in the y axis
for I move.
So I'm going to add a new modifier from the dropdown.
I'm going to choose swizzle input axis values.
That's how we swizzle or change the axis that this key will feed data into.
And if I open the dropdown, we see the order.
The order is set to y, x, z by default, input goes into the x axis first, but if we swizzle it,
it now goes into the y axis first.
So now W will feed data into the y axis.
So that takes care of moving forward.
But I want to move backward as well.
So I'm going to add yet another binding.
And for this one I'll click the keyboard and press s.
This will be for moving backward.
Now this one is going to need a couple of modifiers, right?
For one, we know we'll need to swizzle it like we did with W into the Y axis, but we also want to
negate this input value so we get a negative value and we'll know that we can move backward in that
case.
So we'll add two modifiers.
The first one is going to be the negate, and then we'll add a second modifier that will be swizzle
input axis values.
And as we can see, it's going to go into the Y axis as that's the first letter in the order.
So now that we have an input mapping context and we have Wasd keys set to feed the correct data into
the 2D axis values for a move, we need to actually use that data to move the character.
Now we could do this in the character class if we like, but in this project we're going to handle controlling
the character in the player controller class.
We don't want to crowd up the character class with too many responsibilities and the player controller
class is a perfectly valid class to handle movement for the character that that controller is possessing.
So our next step is to create an aura player controller class, and that's going to be your quest.
Create a new class based on player controller and call it aura player controller.
If you're following along with the same naming conventions now, make sure that this goes into its own
player folder, just like our characters went into our own character folder.
Pause the video and conquer this quest now.
Okay, so I need a new C plus plus class.
I'm going to go into C plus plus classes and aura and public and we'll right click right here to make
a new C plus plus class.
And this will be a player controller.
So here's the player controller class clicking next.
And instead of just going straight into the public folder, I want to be organized.
So I'm going to type slash player and we'll put the player controller in the player folder and I'm going
to call this class Aura player controller.
So let's go ahead and create that class and I'm going to click No so I can compile this myself and I'll
go ahead and close out of the editor and there's my player folder here in Writer, and we now have Aura
Player controller, Dot H and CPP.
So we're ready to associate our enhanced input action and input mapping context with our character.
We're going to do so in Aura Player Controller and we're going to do that in the next video.
So great job this video and I'll see you soon.