Axis Mappings and Action Mappings can be added to your game via the UE4 Editor, but we can also add them directly from C++ code. Since the wireup to C++ functions is from C++ code anyway, you may find it convenient to define your Axis and Action Mappings in C++ as well.
You need a UE4 project to which you'd like to add some Axis and Action mappings. You can delete the existing Axis and Action mappings listed in Settings | Project Settings | Input if you are adding them via C++ code. To add your custom axis and action mappings, there are two C++ functions that you need to know about: the UPlayerInput::AddAxisMapping
and UPlayerInput:: AddActionMapping
. These are member functions available on the UPlayerInput
object. The UPlayerInput
object is inside the PlayerController
object, accessible via the following code:
GetWorld()->GetFirstPlayerController()->PlayerInput
You can also use the two static member functions of UPlayerInput
to create...