WEBVTT

00:06.910 --> 00:08.280
Welcome back.

00:08.290 --> 00:15.340
So in the last video we made our aura input component, which has this nice function, bind, ability

00:15.340 --> 00:16.330
actions.

00:16.480 --> 00:24.070
Now it takes an input config, a user object and three functions, and it's a template type.

00:24.070 --> 00:32.890
So really it's capable of handling whatever we pass in, provided that what bind action does to it supports

00:32.890 --> 00:39.910
those types, but it supports function types and functions that can even take input parameters.

00:39.910 --> 00:46.660
And the way bind action works is it takes a function and then followed by that function we can pass

00:46.660 --> 00:55.800
in inputs that will be passed along into those callbacks when input is pressed, released or held respectively.

00:55.810 --> 01:02.230
So we need to tie this all together by calling this function in our player controller.

01:02.230 --> 01:04.360
And that means we need three functions.

01:04.360 --> 01:12.860
We need a ability input pressed, a released and a held callback that we can bind to these and these

01:12.860 --> 01:14.360
can take input tags.

01:14.360 --> 01:15.380
Pretty cool.

01:15.380 --> 01:22.550
So let's make those functions on the player controller and also we'll add a data asset to the player

01:22.550 --> 01:25.520
controller for the input config.

01:25.520 --> 01:27.230
We'll go ahead and add that first.

01:27.230 --> 01:30.950
That's going to be a private variable down here at the bottom.

01:30.950 --> 01:38.390
So let's make a T object pointer of type U aura input config.

01:38.390 --> 01:45.800
We'll go ahead and just make it this class and this will be input config and we'll forward declare this

01:45.800 --> 01:46.220
here.

01:46.220 --> 01:53.660
So all the way up at the top, let's say class U aura input config.

01:53.840 --> 01:56.420
That way we won't have to include it here.

01:56.900 --> 02:05.420
Now this I want to set from the blueprint so u property for this edit defaults only and we'll give it

02:05.420 --> 02:08.750
a category of of input.

02:09.770 --> 02:15.410
So now that we have an input config, we need three functions, we need three callbacks.

02:15.410 --> 02:17.690
So let's add those three callbacks here.

02:17.690 --> 02:19.040
We'll put it right here.

02:19.040 --> 02:25.940
So first we'll have a void function called ability input tag pressed.

02:26.000 --> 02:36.590
It'll take a gameplay tag, so we'll make it an gameplay tag called input tag and we'll have one for

02:36.590 --> 02:37.220
released.

02:37.220 --> 02:42.830
So void ability input tag released.

02:44.110 --> 02:51.250
It'll also take a gameplay tag called input tag and one for when held.

02:51.250 --> 02:57.280
So void ability input tag held which also takes a tag.

02:57.280 --> 02:58.990
So we have these three functions.

02:58.990 --> 03:03.610
They can be private, they're internal here to our player controller.

03:03.610 --> 03:07.420
Let's generate function definitions for all three.

03:09.380 --> 03:10.490
Here we go.

03:12.010 --> 03:12.970
All right.

03:13.060 --> 03:17.260
Now hovering over the red squiggles gameplay tag is incomplete.

03:17.290 --> 03:19.600
We're not using gameplay tags yet.

03:19.630 --> 03:27.670
Now we're not using references for our gameplay tags here, which means it's an undefined type.

03:27.670 --> 03:33.460
Even in here we are player controller, so I'm just going to go ahead and include gameplay tag container

03:33.460 --> 03:35.020
here in the header file.

03:35.320 --> 03:39.450
So include gameplay tag container age.

03:39.490 --> 03:41.110
That'll take care of that.

03:41.170 --> 03:48.010
And now we need to bind these three to all of our inputs in the data asset, our input config, and

03:48.010 --> 03:51.760
we're going to do that in setup input component right here.

03:51.820 --> 03:59.020
Now we haven't set our new custom input component to be the project's input component yet, but we're

03:59.020 --> 04:05.650
going to and that means rather than casting to you enhanced input component, we're now going to cast

04:05.650 --> 04:12.340
to you or to input component so you ora input component.

04:12.430 --> 04:19.810
And we'll now call this ora input component and we're going to cast to Ora input component and we're

04:19.810 --> 04:26.110
going to take Ora input component and use that instead when we bind our move function to the move action.

04:26.110 --> 04:32.610
And now we should have an Ora input component that we can call our new function on.

04:32.620 --> 04:35.440
Now real quick, I'm going to scroll up to the top.

04:35.740 --> 04:41.200
I see that I have enhanced input component, but now that we're using Ora input component, which includes

04:41.200 --> 04:43.990
enhanced input component, we don't need this anymore.

04:43.990 --> 04:46.900
So I removed enhanced input component.

04:46.930 --> 04:47.350
Okay.

04:47.350 --> 04:53.110
So I'd like to call our function on Ora input component bind ability actions.

04:53.110 --> 04:54.460
So let's do it.

04:55.030 --> 05:00.820
So we're going to take Ora input component and call bind ability actions.

05:00.850 --> 05:08.710
The first input is our data asset called input config and we added that to our player controller down

05:08.710 --> 05:09.310
here.

05:09.310 --> 05:11.260
It's called input config.

05:11.260 --> 05:14.150
That's what we're going to pass in right there.

05:14.180 --> 05:18.510
After that, we have a user class we're going to pass in this.

05:18.530 --> 05:20.150
This is the user class.

05:20.150 --> 05:23.050
And then the last three inputs are the functions.

05:23.060 --> 05:24.770
These are the callbacks.

05:24.950 --> 05:27.440
So let's pass those in.

05:27.770 --> 05:30.590
Now we're passing them in by pointer.

05:30.620 --> 05:32.300
Now we can use this class.

05:32.300 --> 05:37.430
If you didn't know about this class, it's just the class that we're in and we can pass in ability input

05:37.460 --> 05:39.170
tag pressed.

05:39.230 --> 05:41.360
Now the order matters here right?

05:41.360 --> 05:46.580
The first one is the pressed func, next is the released and then finally the held.

05:46.580 --> 05:50.990
So we have this class for the ability input tag pressed.

05:51.440 --> 06:00.980
Next we have ability input tag released and finally this class ability input tag held.

06:01.190 --> 06:02.840
And it's as simple as that.

06:02.840 --> 06:05.030
We've bound our input actions.

06:05.030 --> 06:12.290
I'm going to go ahead and get rid of some of these empty spaces, compact it a little bit and this is

06:12.290 --> 06:21.020
actually quite cool because now, provided that we go and set our input component to Ora input component,

06:21.050 --> 06:26.240
we're casting checked here, which means we have to or we'll crash the game.

06:26.240 --> 06:33.050
But now, thanks to bind ability input actions, when we press any of those inputs in our data asset,

06:33.080 --> 06:42.920
then our three callbacks will be fired off and we can actually prove that we can use a Yui log or an

06:42.950 --> 06:44.210
on screen debug message.

06:44.210 --> 06:45.290
Let's do a debug message.

06:45.290 --> 06:47.900
We'll say Gee engine.

06:50.340 --> 06:53.370
Add on screen debug message for pressed.

06:53.400 --> 06:56.910
We'll go ahead and just use three different keys.

06:56.910 --> 07:04.440
We'll use the key one for pressed time to display can be let's make it three seconds.

07:05.070 --> 07:13.440
F color for pressed will be red and the string will say let's actually print the name of the tag.

07:13.440 --> 07:21.870
So we'll use star input tag dot to string and that way we'll know that our callback is receiving the

07:21.870 --> 07:23.820
correct tag for the correct input.

07:23.820 --> 07:27.110
And then we don't really need anything else.

07:27.120 --> 07:32.670
I'm going to copy this line and paste it in here for the released only for release.

07:32.670 --> 07:34.980
I'll use a different key we'll use to.

07:35.550 --> 07:42.330
And for the color we'll use blue and then I'll copy the whole thing, paste it in for held for held.

07:42.330 --> 07:43.680
We'll use the key three.

07:43.710 --> 07:51.240
This just ensures that the pressed messages will replace each other, but they won't replace the released

07:51.240 --> 07:52.380
or held messages.

07:52.380 --> 07:53.610
That's how it'll work.

07:53.820 --> 07:56.340
And for held, let's use green.

07:56.820 --> 08:01.340
Okay, so all that's left is to prove to ourselves that this is all working.

08:01.350 --> 08:07.560
So what I'm going to do is run in debug mode, let's compile and launch and we need to set our input

08:07.560 --> 08:13.350
component for the project to our new input component class that we've created.

08:13.440 --> 08:14.910
So let's do that.

08:16.890 --> 08:17.640
Okay.

08:17.640 --> 08:19.110
Compiled and launched.

08:19.140 --> 08:24.390
Now we need to go to edit and project settings and into input.

08:24.390 --> 08:31.830
And then all the way down at the bottom, our default input component class is set to enhanced input

08:31.830 --> 08:37.020
component, but if we open the dropdown, we can choose aura input component.

08:37.050 --> 08:39.210
We have to very important.

08:39.210 --> 08:42.700
So now that we've done that, now we can test things out.

08:42.720 --> 08:44.130
I'm going to press play.

08:45.590 --> 08:49.480
And it looks like I got a breakpoint.

08:49.490 --> 08:53.690
We're stuck right here at the check for input config.

08:53.690 --> 09:00.590
And of course that's because I forgot to set the input config on our player controller.

09:00.590 --> 09:07.460
So our player controller is passing in a null pointer here and the check is going to trigger this breakpoint

09:07.460 --> 09:08.060
here.

09:08.150 --> 09:10.190
So that's okay.

09:10.190 --> 09:17.690
Well we can do is we can hit stop, we can run in debug mode again and we can go ahead and set the input

09:17.690 --> 09:20.120
config on our player controller.

09:20.510 --> 09:27.620
Now I'm going to first go to project settings and go down to input, make sure that it's ora input component.

09:27.620 --> 09:35.600
Yes, that change has saved and now we can open up our blueprints folder, go to player and BP or a

09:35.600 --> 09:38.030
player controller and there's our input config.

09:38.030 --> 09:39.230
I forgot to set it.

09:39.260 --> 09:42.980
Once we set that to ora input config compile.

09:42.980 --> 09:46.410
Now we can press play and we can test things out.

09:46.440 --> 09:48.960
Now I'm going to click with my left mouse button.

09:48.960 --> 09:55.350
I'm going to wait till those messages go away and I'm going to left click and I'm holding it down and

09:55.350 --> 09:57.360
I'm going to release.

09:57.360 --> 09:59.520
And as soon as I release I get the blue.

09:59.520 --> 10:01.740
So red is pressed.

10:01.740 --> 10:05.700
And then as long as I'm holding it down, I got it still held down.

10:05.700 --> 10:07.080
I have the green.

10:07.080 --> 10:09.510
And then if I release, I get the blue.

10:09.540 --> 10:12.240
Let's see if my right mouse button does the same.

10:12.240 --> 10:14.880
So I'm going to right click and hold it down.

10:14.880 --> 10:16.920
So the red is for pressing.

10:16.920 --> 10:18.540
I'm still holding it down.

10:18.540 --> 10:24.000
Green is for being held and releasing is the blue and they all stay for three seconds.

10:24.030 --> 10:29.160
Now we did keys one through four as well, so I can press the one key.

10:29.190 --> 10:31.020
There's input tag one.

10:31.020 --> 10:32.700
I'm holding it down now.

10:32.700 --> 10:34.920
I'm going to release There we go.

10:34.920 --> 10:36.690
And I can press the two key.

10:36.720 --> 10:41.430
There's the red for two and I see that I'm still holding it down.

10:41.430 --> 10:42.930
I release there's the blue.

10:42.960 --> 10:44.850
Here's three release.

10:44.850 --> 10:46.890
There's the blue for four.

10:46.890 --> 10:47.910
You get the idea.

10:48.000 --> 10:49.500
It's working.

10:49.500 --> 10:51.450
That is great.

10:51.630 --> 10:53.790
So now we have data driven input.

10:53.790 --> 10:57.900
This is really powerful because we can always swap out the data asset.

10:57.930 --> 11:03.690
We can configure things in the data asset and everything is associated with input tags.

11:03.690 --> 11:10.410
So it's really important that we can see the input tag associated with any of these given inputs as

11:10.410 --> 11:12.000
we trigger those inputs.

11:12.030 --> 11:12.480
Why?

11:12.510 --> 11:17.880
Because if we have access to them in C plus plus, well, we have a lot of power.

11:18.000 --> 11:23.910
I'm going to close the editor saving all and go back to the Ora player controller here.

11:23.910 --> 11:31.740
And now that we have three callback functions, we can now use these tags to activate abilities as long

11:31.740 --> 11:34.860
as abilities have tags associated with them.

11:34.860 --> 11:41.610
So our next step is to associate our gameplay abilities with some kind of input tag.

11:41.610 --> 11:48.650
And this is great because if we can swap out the input tag for a given ability, then we can remap it

11:48.650 --> 11:51.050
to a different key at runtime.

11:51.200 --> 11:54.170
So this is actually really exciting.

11:54.170 --> 11:56.570
So great job setting this all up.

11:56.570 --> 12:02.330
We're getting our framework in place for a really robust system and it's going to be really exciting.

12:02.330 --> 12:07.040
And we're about ready to wrap up the video now.

12:07.040 --> 12:13.310
One kind of cool thing is that these functions can be made static writers telling us that that's because

12:13.310 --> 12:20.150
they don't require any member variables or anything that requires an actual instance of anything to

12:20.150 --> 12:21.020
exist.

12:21.020 --> 12:23.240
So these could be static functions.

12:23.240 --> 12:26.450
We can also refactor our cursor trace function.

12:26.450 --> 12:29.540
We can make this a great deal more compact.

12:29.540 --> 12:34.820
So there will be some refactoring that we'll do pretty soon as well in the player controller while we're

12:34.820 --> 12:37.280
here so we can make things look nice and pretty.

12:37.280 --> 12:40.490
We want nice professional code for all of this.

12:40.490 --> 12:43.190
So really exciting stuff coming up.

12:43.190 --> 12:45.980
Excellent job and I'll see you in the next video.
