Welcome back.
So in the last video we made our aura input component, which has this nice function, bind, ability
actions.
Now it takes an input config, a user object and three functions, and it's a template type.
So really it's capable of handling whatever we pass in, provided that what bind action does to it supports
those types, but it supports function types and functions that can even take input parameters.
And the way bind action works is it takes a function and then followed by that function we can pass
in inputs that will be passed along into those callbacks when input is pressed, released or held respectively.
So we need to tie this all together by calling this function in our player controller.
And that means we need three functions.
We need a ability input pressed, a released and a held callback that we can bind to these and these
can take input tags.
Pretty cool.
So let's make those functions on the player controller and also we'll add a data asset to the player
controller for the input config.
We'll go ahead and add that first.
That's going to be a private variable down here at the bottom.
So let's make a T object pointer of type U aura input config.
We'll go ahead and just make it this class and this will be input config and we'll forward declare this
here.
So all the way up at the top, let's say class U aura input config.
That way we won't have to include it here.
Now this I want to set from the blueprint so u property for this edit defaults only and we'll give it
a category of of input.
So now that we have an input config, we need three functions, we need three callbacks.
So let's add those three callbacks here.
We'll put it right here.
So first we'll have a void function called ability input tag pressed.
It'll take a gameplay tag, so we'll make it an gameplay tag called input tag and we'll have one for
released.
So void ability input tag released.
It'll also take a gameplay tag called input tag and one for when held.
So void ability input tag held which also takes a tag.
So we have these three functions.
They can be private, they're internal here to our player controller.
Let's generate function definitions for all three.
Here we go.
All right.
Now hovering over the red squiggles gameplay tag is incomplete.
We're not using gameplay tags yet.
Now we're not using references for our gameplay tags here, which means it's an undefined type.
Even in here we are player controller, so I'm just going to go ahead and include gameplay tag container
here in the header file.
So include gameplay tag container age.
That'll take care of that.
And now we need to bind these three to all of our inputs in the data asset, our input config, and
we're going to do that in setup input component right here.
Now we haven't set our new custom input component to be the project's input component yet, but we're
going to and that means rather than casting to you enhanced input component, we're now going to cast
to you or to input component so you ora input component.
And we'll now call this ora input component and we're going to cast to Ora input component and we're
going to take Ora input component and use that instead when we bind our move function to the move action.
And now we should have an Ora input component that we can call our new function on.
Now real quick, I'm going to scroll up to the top.
I see that I have enhanced input component, but now that we're using Ora input component, which includes
enhanced input component, we don't need this anymore.
So I removed enhanced input component.
Okay.
So I'd like to call our function on Ora input component bind ability actions.
So let's do it.
So we're going to take Ora input component and call bind ability actions.
The first input is our data asset called input config and we added that to our player controller down
here.
It's called input config.
That's what we're going to pass in right there.
After that, we have a user class we're going to pass in this.
This is the user class.
And then the last three inputs are the functions.
These are the callbacks.
So let's pass those in.
Now we're passing them in by pointer.
Now we can use this class.
If you didn't know about this class, it's just the class that we're in and we can pass in ability input
tag pressed.
Now the order matters here right?
The first one is the pressed func, next is the released and then finally the held.
So we have this class for the ability input tag pressed.
Next we have ability input tag released and finally this class ability input tag held.
And it's as simple as that.
We've bound our input actions.
I'm going to go ahead and get rid of some of these empty spaces, compact it a little bit and this is
actually quite cool because now, provided that we go and set our input component to Ora input component,
we're casting checked here, which means we have to or we'll crash the game.
But now, thanks to bind ability input actions, when we press any of those inputs in our data asset,
then our three callbacks will be fired off and we can actually prove that we can use a Yui log or an
on screen debug message.
Let's do a debug message.
We'll say Gee engine.
Add on screen debug message for pressed.
We'll go ahead and just use three different keys.
We'll use the key one for pressed time to display can be let's make it three seconds.
F color for pressed will be red and the string will say let's actually print the name of the tag.
So we'll use star input tag dot to string and that way we'll know that our callback is receiving the
correct tag for the correct input.
And then we don't really need anything else.
I'm going to copy this line and paste it in here for the released only for release.
I'll use a different key we'll use to.
And for the color we'll use blue and then I'll copy the whole thing, paste it in for held for held.
We'll use the key three.
This just ensures that the pressed messages will replace each other, but they won't replace the released
or held messages.
That's how it'll work.
And for held, let's use green.
Okay, so all that's left is to prove to ourselves that this is all working.
So what I'm going to do is run in debug mode, let's compile and launch and we need to set our input
component for the project to our new input component class that we've created.
So let's do that.
Okay.
Compiled and launched.
Now we need to go to edit and project settings and into input.
And then all the way down at the bottom, our default input component class is set to enhanced input
component, but if we open the dropdown, we can choose aura input component.
We have to very important.
So now that we've done that, now we can test things out.
I'm going to press play.
And it looks like I got a breakpoint.
We're stuck right here at the check for input config.
And of course that's because I forgot to set the input config on our player controller.
So our player controller is passing in a null pointer here and the check is going to trigger this breakpoint
here.
So that's okay.
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
config on our player controller.
Now I'm going to first go to project settings and go down to input, make sure that it's ora input component.
Yes, that change has saved and now we can open up our blueprints folder, go to player and BP or a
player controller and there's our input config.
I forgot to set it.
Once we set that to ora input config compile.
Now we can press play and we can test things out.
Now I'm going to click with my left mouse button.
I'm going to wait till those messages go away and I'm going to left click and I'm holding it down and
I'm going to release.
And as soon as I release I get the blue.
So red is pressed.
And then as long as I'm holding it down, I got it still held down.
I have the green.
And then if I release, I get the blue.
Let's see if my right mouse button does the same.
So I'm going to right click and hold it down.
So the red is for pressing.
I'm still holding it down.
Green is for being held and releasing is the blue and they all stay for three seconds.
Now we did keys one through four as well, so I can press the one key.
There's input tag one.
I'm holding it down now.
I'm going to release There we go.
And I can press the two key.
There's the red for two and I see that I'm still holding it down.
I release there's the blue.
Here's three release.
There's the blue for four.
You get the idea.
It's working.
That is great.
So now we have data driven input.
This is really powerful because we can always swap out the data asset.
We can configure things in the data asset and everything is associated with input tags.
So it's really important that we can see the input tag associated with any of these given inputs as
we trigger those inputs.
Why?
Because if we have access to them in C plus plus, well, we have a lot of power.
I'm going to close the editor saving all and go back to the Ora player controller here.
And now that we have three callback functions, we can now use these tags to activate abilities as long
as abilities have tags associated with them.
So our next step is to associate our gameplay abilities with some kind of input tag.
And this is great because if we can swap out the input tag for a given ability, then we can remap it
to a different key at runtime.
So this is actually really exciting.
So great job setting this all up.
We're getting our framework in place for a really robust system and it's going to be really exciting.
And we're about ready to wrap up the video now.
One kind of cool thing is that these functions can be made static writers telling us that that's because
they don't require any member variables or anything that requires an actual instance of anything to
exist.
So these could be static functions.
We can also refactor our cursor trace function.
We can make this a great deal more compact.
So there will be some refactoring that we'll do pretty soon as well in the player controller while we're
here so we can make things look nice and pretty.
We want nice professional code for all of this.
So really exciting stuff coming up.
Excellent job and I'll see you in the next video.