2. Configure Game Input

Configuring input in Unreal Engine

On this page

There are two types of input mappings: Action and Axis.

  • Action Mappings are useful to think of as "yes or no" inputs, like the buttons on a mouse or joystick. They report when they are pressed, released, double-clicked, or held down for a short time. Discrete actions like jumping, shooting, or interacting with objects are good candidates for this type of mapping.

  • Axis Mappings are continuous - think of them as "how much" inputs, like the stick on a joystick, or the position of a mouse cursor. They report their value every frame, even if they're not moving. Things with magnitude or direction, such as walking, looking around, and steering a vehicle are usually handled this way.

While input mappings can be defined directly in code, the usual method is to define them in the Unreal Engine editor, so that's how we'll do it in this tutorial.

  1. In the Unreal Engine editor, under the Edit dropdown menu, we'll click the Project Settings option.


  2. From there, we'll select the Input option from the Engine section on the left. We can then expand the Bindings category that appears on the right, and add one Action Mapping and two Axis Mappings.

    The plus sign next to the Action Mapping or Axis Mapping section headings will add a new mapping. The expander arrow on the left can be used to show or hide our mappings. To add an additional input to a mapping, click the plus sign next to that mapping. Following are the mappings and inputs we will need. Take note of the negative values for the S and A inputs.

    Action Mapping


    Space Bar

    Axis Mapping












  3. Now that our input is configured, let's set up a MyPawn in our level. The MyPawn class will appear in our Content Browser, and is ready to be dragged into the Level Editor.



  4. One more step is needed to set up our MyPawn. We'll need to give it a Static Mesh so that we can see it in the game. We can do this by selecting the MyPawn we just created, selecting the component called OurVisibleComponent (Inherited) in the Details Panel, and assigning an asset to it through the dropdown box in the Static Mesh category. For this tutorial, Shape_Cylinder is a good asset to use.


  5. We can now save our level and return to Visual Studio to write code that will make the MyPawn we placed react to the inputs we defined.

We're now ready to finish coding our MyPawn class in Visual Studio.

Work-In-Progress Code


// Copyright 1998-2018 Epic Games, Inc. All Rights Reserved.

#pragma once

#include "GameFramework/Pawn.h"
#include "MyPawn.generated.h"

class HOWTO_PLAYERINPUT_API AMyPawn : public APawn

    // Sets default values

    // Called when the game starts or when spawned
    virtual void BeginPlay() override;

    // Called every frame
    virtual void Tick( float DeltaSeconds ) override;

    // Called to bind functionality to input
    virtual void SetupPlayerInputComponent(class UInputComponent* InputComponent) override;

    USceneComponent* OurVisibleComponent;


// Copyright 1998-2018 Epic Games, Inc. All Rights Reserved.

#include "HowTo_PlayerInput.h"
#include "MyPawn.h"

// Sets default values
    // Set this pawn to call Tick() every frame.  You can turn this off to improve performance if you don't need it.
    PrimaryActorTick.bCanEverTick = true;

    // Set this pawn to be controlled by the lowest-numbered player
    AutoPossessPlayer = EAutoReceiveInput::Player0;

    // Create a dummy root component we can attach things to.
    RootComponent = CreateDefaultSubobject<USceneComponent>(TEXT("RootComponent"));
    // Create a camera and a visible object
    UCameraComponent* OurCamera = CreateDefaultSubobject<UCameraComponent>(TEXT("OurCamera"));
    OurVisibleComponent = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("OurVisibleComponent"));
    // Attach our camera and visible object to our root component. Offset and rotate the camera.
    OurCamera->SetRelativeLocation(FVector(-250.0f, 0.0f, 250.0f));
    OurCamera->SetRelativeRotation(FRotator(-45.0f, 0.0f, 0.0f));

// Called when the game starts or when spawned
void AMyPawn::BeginPlay()


// Called every frame
void AMyPawn::Tick( float DeltaTime )
    Super::Tick( DeltaTime );


// Called to bind functionality to input
void AMyPawn::SetupPlayerInputComponent(class UInputComponent* InputComponent)

Select Skin

Welcome to the new Unreal Engine 4 Documentation site!

We're working on lots of new features including a feedback system so you can tell us how we are doing. It's not quite ready for use in the wild yet, so head over to the Documentation Feedback forum to tell us about this page or call out any issues you are encountering in the meantime.

We'll be sure to let you know when the new system is up and running.

Post Feedback