Write Function for User Inputs

Where do you find/edit functions which are triggered by user inputs? For example, if I trigger the function “moveX” when the user presses ‘1’, where do I define what the function “moveX” does?

After you set up Input Mappings in the editor, you need bind them to functions in your character’s class.

Sample code:



void AYourCharacter::SetupPlayerInputComponent(class UInputComponent* InputComponent)
{
    //Set up gameplay key bindings
    check(InputComponent);

    //... Some code here    

    InputComponent->BindAxis("YOUR_MAPPING", this, &AYourCharacter::YourFunction);

    //... More code here
}


Then, you can define YourFunction like this:



void AMyCharacter::YourFunction(float Value)
{
    //Some logic here
}


More info and movement example here: https://docs.unrealengine.com/latest/INT/Gameplay/Input/index.html

Hope this helps. :slight_smile: