‫Hello and welcome.
‫In this lecture, we're going to be setting up remap able inputs so that when we press down or either
‫on the mouse key or on a controller, we get a press and release message coming through from Blueprint.
‫Let's dive in and see how to do this now.
‫We don't want to be doing this trace all the time.
‫We only need to be doing it when we're getting ready to grab an object and we don't want to automatically
‫grab it when we go near it.
‫So to actually grab onto something, we need to use a mouse input, some sort of input.
‫Now previously we've done this with events in Blueprint and we're going to do it again with events.
‫We will see how to do this in C++ soon, but we are going to first do it with events.
‫And what I want to do is set it up so that it could work with the keyboard, it could work with the
‫mouse, or it could work with a controller.
‫So to do this, we need input mapping, something that you see quite often in games.
‫And the way we're going to do this is go to our settings COG, we're going to go to the project settings,
‫scroll down to the engine and then input.
‫Here is where we set up things called action mappings and axis mappings.
‫So what these two concepts are are essentially the mappings between your controller analog sticks or
‫buttons, or perhaps your mouse and your mouse buttons or your keyboard.
‫The actions are discrete things.
‫These are things that you press a button and it just happens as a press, as a release.
‫And the axis mappings are things which are more continuous, such as when you move a mouse slightly
‫or you slightly tilt a controller, there's a degree to which you can tilt it.
‫You can tilt it, not at all.
‫You can tell to all the way or anywhere in between.
‫Those are axes.
‫We're not going to deal with axes in this section because all we're dealing with is an action where
‫we are trying to activate our grabber component.
‫So the way we're going to do this is to unfold our action mapping.
‫So you can see there's already a couple of action mappings here.
‫There's a jump and then there's a primary action.
‫This has been set up for us because we're using the first person template and there is a primary action
‫already here.
‫Now let's unfold that primary action and you will see that there are two ways to trigger the primary
‫action.
‫You can use the left mouse button or the gamepad right trigger.
‫Now, because I want to give you an idea of how we can set up our own action mapping.
‫I'm actually going to hit the delete button next to the primary action and we're going to create our
‫own.
‫So the first thing to do is click the add button next to action mapping.
‫Then we need to give this action a name.
‫In my case, I'm going to call this grab and then we need to select a mapping.
‫Now you can either do this from the dropdown where you can select any of the mappings in here, or you
‫can click on that little keyboard button which allows you to capture whatever you're doing.
‫So you click on it, it goes yellow and then you click again or you use whatever key.
‫If I hit space, you can see it puts in space bar.
‫If I actually click with my left mouse button, you can see it adds a left mouse button option here.
‫So a little mini challenge for you now is to go ahead and set up this action mapping, add the left
‫mouse button.
‫Maybe if you've got a controller, add in a controller button here to.
‫Okay.
‫Welcome back.
‫So I'm going to add in a new action mapping is this add button.
‫And then what we can do is we can I don't have my controller hooked up at the moment.
‫So what you can do is click the dropdown and we can go to gamepad and you can look for the gamepad right
‫trigger, for example, and that will set it up so that when you pull the trigger on your gamepad,
‫it's going to activate our grab action.
‫So we've set up the action mapping.
‫Now we need to actually make use of it.
‫So we're going to go over to our content draw.
‫We're going to look for our beep player and open it up because the beep player is the one that has the
‫grabber component.
‫And that's what we're eventually going to want to activate and make it grab something.
‫And the way we can do this is by right clicking in the Blueprint Event graph and searching for grab.
‫So now there is an input action events grab event and this is linked up to whatever keys you have set
‫up and you can change that and you can potentially create screens in the game which allow your players
‫to change the input mappings as well.
‫And what you got here is two events, a press event and a released event.
‫So I'd like to challenge you to log on that particular action.
‫So add a blueprint log for when it's pressed, add it for when it's released, and check that your mappings
‫work.
‫So go into the game.
‫Use the particular keys that you've mapped to grab action and see if your log messages get printed out.
‫Pause the video and have a go.
‫Hey, welcome back.
‫So for pressed, we are going to do a print string, which is not going to say hello.
‫It's going to say grabbed and then we're going to have a released one as well.
‫Again, a print string which is going to say released like.
‫So now let's go ahead into our dungeon level and hit play.
‫And now if we hit the mouse button, it says grabbed.
‫When I release it, it says released.
‫And you can see that that is working as we would expect.
‫Great stuff.
‫Now we've seen how we can set up action mappings that are remap able and map able to multiple inputs.
‫I'll see you in the next lecture.