Axis mapping doesn't move pawn on editor

I’m trying to move a C++ Pawn class on axis Z.

I have defined this on Unreal Editor → Project Properties…

And this is the C++ Pawn class body:

#include "Paddle.h"
#include "Components/BoxComponent.h"
#include "Components/StaticMeshComponent.h"
#include "Components/InputComponent.h"

// Sets default values
 	// Set this actor 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;

	MeshComp = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("MeshComp"));
	// Disable collision.
	// Set the first object in the hierachy.
	RootComponent = MeshComp;

	CollisionComponent = CreateDefaultSubobject<UBoxComponent>(TEXT("CollisionComp"));
	// No physics, queries only.
	// It will generate the 'Hit' event.
	CollisionComponent->SetCollisionResponseToChannel(ECollisionChannel::ECC_Pawn, ECollisionResponse::ECR_Block);


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

void APaddle::SetupPlayerInputComponent(UInputComponent* PlayerInputComponent)

	// Respond every frame to the values of our movement.
	InputComponent->BindAxis(TEXT("MovePaddle"), this, &APaddle::Move_ZAxis);

void APaddle::Move_ZAxis(float AxisValue)
	CurrentVelocity.Z = FMath::Clamp(AxisValue, -1.0f, 1.0f) * 100.0f;

// Called every frame
void APaddle::Tick(float DeltaTime)

	// Handle movement based on our "MoveZ" axis.
	if (!CurrentVelocity.IsZero())
		const FVector NewLocation = GetActorLocation() + (CurrentVelocity * DeltaTime);

And this is the header file:

#pragma once

#include "CoreMinimal.h"
#include "GameFramework/Actor.h"
#include "Paddle.generated.h"

class UBoxComponent;

class PONG_API APaddle : public APawn
	// Sets default values for this actor's properties

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

	virtual void SetupPlayerInputComponent(class UInputComponent* PlayerInputComponent) override;

	// Input functions
	void Move_ZAxis(float AxisValue);

	UPROPERTY(VisibleAnywhere, Category = "Components")
	UBoxComponent* CollisionComponent;

	UPROPERTY(VisibleAnywhere, Category = "Components")
	UStaticMeshComponent* MeshComp;

	// Input variables
	FVector CurrentVelocity;

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


To try it, I press Play button on editor but when I press R or F key nothing happens.

I’ve been searching for a tutorial about how to do it, or sample code, or book, but it seems that I’m not searching correctly because I haven’t found anything useful.

Why it doesn’t work?

By the way, I have blueprinted the C++ to add it to the editor.

Hello, I think the problem is that the Move_ZAxis function hasn’t been marked as a UFUNCTION.

Just add “UFUNCTION()” on the line before the Move_ZAxis prototype

All functions that are bound to events and such need to be marked as UFUNCTIONs.

Recommendation: You should look into logging with Unreal Engine, as it can be a great tool for debugging. Example:
UE_LOG(LogTemp, Warning, TEXT("My Test Log")) will print a log to the Output Log when executed.

Hope this helps!

Oh, and you should also add this to the Constructor (right after setting MeshComp`s collision):


This will mark the Component as Movable (default is Static), which will allow it to move around.