WEBVTT

00:06.830 --> 00:08.020
Welcome back.

00:08.030 --> 00:13.790
Now that we have our character and our enemies, we need to be able to move them around.

00:13.880 --> 00:17.780
This means we need to be able to handle input specifically for Aura.

00:17.780 --> 00:20.360
We're going to deal with the Aura character first.

00:20.360 --> 00:25.730
And in order to move or around in the level, we need to handle input.

00:25.730 --> 00:30.530
And the way to do that is to set up enhanced input for our character.

00:30.530 --> 00:32.210
So we're going to do that.

00:32.210 --> 00:37.820
I have a lot of windows open here, so what I'm going to do is hover over each of the tabs and simply

00:37.820 --> 00:40.670
click the Middle Mouse button to close those.

00:40.670 --> 00:42.890
So closing all of these down.

00:46.540 --> 00:50.320
Now we've got that under control and we can set up enhanced input.

00:50.350 --> 00:53.770
Now for movement, we're going to need an input action.

00:53.770 --> 01:00.850
So in my content drawer in Blueprints, I'm going to create a new folder called Input.

01:01.600 --> 01:07.180
And here in input, I'm going to make yet another folder called Input Actions.

01:08.230 --> 01:13.010
And all of our input actions will go into this folder for this project.

01:13.030 --> 01:20.380
Now an input action is required for enhanced input in order to take input from some sort of device such

01:20.380 --> 01:21.400
as the keyboard.

01:21.400 --> 01:28.060
So for movement, we're going to make a new input action by right clicking, going to input and selecting

01:28.060 --> 01:29.140
input action.

01:29.140 --> 01:34.480
And the convention is to put in a for input action and we'll call this one move.

01:34.510 --> 01:40.690
Now I'm going to open up a move and the only thing I really want to change here is the value type,

01:40.690 --> 01:46.190
because for movement, I want to be able to handle two dimensional movement.

01:46.190 --> 01:51.500
Left and right is the first dimension forward and backward is the second dimension.

01:51.500 --> 01:58.460
So I'm going to change this value type to access 2D vector 2D that's going to allow me to take input

01:58.460 --> 02:03.080
in the form of a two dimensional vector with two axes X and y.

02:03.110 --> 02:08.170
I'd like to consider X to be left and right and Y to be forward and backward.

02:08.180 --> 02:09.830
Now, let's not get confused.

02:09.830 --> 02:16.730
Here in three dimensional space, we typically consider an actor's forward vector to be the x axis for

02:16.760 --> 02:17.750
that actor.

02:17.750 --> 02:22.070
But for movement, we're talking about a 2D axis space.

02:22.100 --> 02:25.220
Look at the Wasd keys on your keyboard.

02:25.220 --> 02:28.190
W and X will be forward and backward.

02:28.190 --> 02:32.450
We're going to consider that to be the Y axis in this 2D space.

02:32.480 --> 02:34.550
A and D will be left and right.

02:34.580 --> 02:39.140
We'll consider that the x axis in this 2D space.

02:39.140 --> 02:44.750
So now that we have an input action, the way that we link this to our character is going to be through

02:44.750 --> 02:52.490
an input mapping context and that's where we can associate keyboard keys with our input action to move.

02:52.520 --> 02:56.990
So back in our input folder, I'm going to go back up one level.

02:56.990 --> 03:00.290
We'll put our input mapping context right here.

03:00.290 --> 03:06.920
So I'm going to right click, go to input and select input mapping context, and I'll call this emcee

03:06.950 --> 03:10.850
for input mapping, context or context.

03:10.940 --> 03:13.340
And I'll go ahead and open this up.

03:13.340 --> 03:19.280
And here we have our mappings, an empty array currently, but if I click plus I can add one and open

03:19.280 --> 03:22.280
the dropdown and select an input action.

03:22.280 --> 03:27.560
Opening this up, I see that the only one available is the one I just made I a move.

03:27.560 --> 03:35.450
I'll select that Now that we have a move in this input mapping context, we need to associate it with

03:35.450 --> 03:37.310
various forms of input.

03:37.340 --> 03:44.780
Now, for the time being, I'm just going to set up Wasd movement at this stage in the course.

03:44.780 --> 03:50.570
So what I'll do is I'll click on the keyboard icon here and then press D.

03:50.930 --> 03:52.400
We'll start with the D key.

03:52.400 --> 03:55.370
The key is perhaps the most simple.

03:55.370 --> 03:58.700
When we press D, we want to move to the right.

03:58.730 --> 04:05.960
Now I'd like to add additional keys to this, so I'm going to press the plus icon next to move and get

04:05.960 --> 04:07.610
another mapping.

04:07.610 --> 04:13.340
I'm going to click the keyboard icon and press A now pressing D moves us to the right.

04:13.340 --> 04:20.570
Pressing A is going to move us to the left, which means further down the line in our code, when we

04:20.600 --> 04:27.200
set up the ability to respond to user input, we're going to access data that we retrieve as a result

04:27.200 --> 04:33.260
of these mappings and pressing D and A will both result in us retrieving data.

04:33.260 --> 04:37.070
But when I press A, I'd like that data to be negative.

04:37.070 --> 04:43.850
I want to receive a positive one when I'm pressing D and negative one when I'm pressing A and in order

04:43.850 --> 04:48.080
to do that I have to modify that input using a modifier.

04:48.080 --> 04:54.710
So under a I'm going to click plus for the modifiers and for this modifier, I'll open the dropdown

04:54.710 --> 04:56.090
and choose negate.

04:56.120 --> 05:03.470
If I open that index, I see that it's going to negate all three axes, but D and A are just going to

05:03.470 --> 05:05.240
be on the x axis.

05:05.240 --> 05:10.580
And remember, a move is a two dimensional input action with two axes.

05:10.580 --> 05:15.290
So the Z axis here has no meaning for us in any of our modifiers.

05:15.290 --> 05:20.600
For I a move but D and A those are going into the x axis.

05:20.600 --> 05:23.720
Remember I said A and D is left and right.

05:23.870 --> 05:29.930
We're considering that the x axis in this two dimensional space for I a move.

05:29.930 --> 05:32.570
So we're going to negate that x axis.

05:32.600 --> 05:37.520
We don't need Y or Z checked, we just want to negate the x axis here.

05:37.670 --> 05:41.990
So that takes care of D and A, but we want to move forward and backward as well.

05:41.990 --> 05:46.070
So I'm going to click Plus to add another key, click the keyboard.

05:46.090 --> 05:50.380
Icon and press W and this will be for moving forward.

05:50.590 --> 05:52.630
Now, we don't want to negate it.

05:52.660 --> 05:56.440
When I press w, I want to receive a positive one value.

05:56.470 --> 06:00.220
However, I don't want to receive it on the x axis.

06:00.250 --> 06:06.500
In the two dimensional space for I a move I want to receive a positive one in the y axis.

06:06.520 --> 06:15.520
For that reason I have to add a modifier that will force the W key to provide input data in the y axis

06:15.520 --> 06:16.660
for I move.

06:16.690 --> 06:19.980
So I'm going to add a new modifier from the dropdown.

06:19.990 --> 06:22.960
I'm going to choose swizzle input axis values.

06:22.960 --> 06:29.220
That's how we swizzle or change the axis that this key will feed data into.

06:29.230 --> 06:32.230
And if I open the dropdown, we see the order.

06:32.260 --> 06:39.640
The order is set to y, x, z by default, input goes into the x axis first, but if we swizzle it,

06:39.640 --> 06:42.280
it now goes into the y axis first.

06:42.280 --> 06:46.370
So now W will feed data into the y axis.

06:46.370 --> 06:48.440
So that takes care of moving forward.

06:48.440 --> 06:50.120
But I want to move backward as well.

06:50.120 --> 06:53.420
So I'm going to add yet another binding.

06:53.600 --> 06:57.230
And for this one I'll click the keyboard and press s.

06:57.260 --> 06:59.200
This will be for moving backward.

06:59.210 --> 07:02.510
Now this one is going to need a couple of modifiers, right?

07:02.510 --> 07:09.110
For one, we know we'll need to swizzle it like we did with W into the Y axis, but we also want to

07:09.110 --> 07:14.750
negate this input value so we get a negative value and we'll know that we can move backward in that

07:14.750 --> 07:15.440
case.

07:15.560 --> 07:17.150
So we'll add two modifiers.

07:17.150 --> 07:23.300
The first one is going to be the negate, and then we'll add a second modifier that will be swizzle

07:23.300 --> 07:24.800
input axis values.

07:24.800 --> 07:32.120
And as we can see, it's going to go into the Y axis as that's the first letter in the order.

07:32.120 --> 07:39.950
So now that we have an input mapping context and we have Wasd keys set to feed the correct data into

07:39.950 --> 07:47.090
the 2D axis values for a move, we need to actually use that data to move the character.

07:47.090 --> 07:53.030
Now we could do this in the character class if we like, but in this project we're going to handle controlling

07:53.030 --> 07:55.760
the character in the player controller class.

07:55.760 --> 08:01.910
We don't want to crowd up the character class with too many responsibilities and the player controller

08:01.910 --> 08:09.440
class is a perfectly valid class to handle movement for the character that that controller is possessing.

08:09.530 --> 08:16.970
So our next step is to create an aura player controller class, and that's going to be your quest.

08:16.970 --> 08:23.000
Create a new class based on player controller and call it aura player controller.

08:23.000 --> 08:29.330
If you're following along with the same naming conventions now, make sure that this goes into its own

08:29.330 --> 08:34.100
player folder, just like our characters went into our own character folder.

08:34.160 --> 08:37.280
Pause the video and conquer this quest now.

08:40.270 --> 08:43.090
Okay, so I need a new C plus plus class.

08:43.090 --> 08:49.000
I'm going to go into C plus plus classes and aura and public and we'll right click right here to make

08:49.000 --> 08:50.410
a new C plus plus class.

08:50.410 --> 08:52.900
And this will be a player controller.

08:53.140 --> 08:56.560
So here's the player controller class clicking next.

08:56.560 --> 09:01.150
And instead of just going straight into the public folder, I want to be organized.

09:01.150 --> 09:07.480
So I'm going to type slash player and we'll put the player controller in the player folder and I'm going

09:07.480 --> 09:10.390
to call this class Aura player controller.

09:10.390 --> 09:16.780
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

09:16.780 --> 09:23.170
go ahead and close out of the editor and there's my player folder here in Writer, and we now have Aura

09:23.170 --> 09:25.840
Player controller, Dot H and CPP.

09:26.230 --> 09:34.120
So we're ready to associate our enhanced input action and input mapping context with our character.

09:34.120 --> 09:40.040
We're going to do so in Aura Player Controller and we're going to do that in the next video.

09:40.040 --> 09:42.920
So great job this video and I'll see you soon.
