How to get input from APawn?

I’ve got a class that extends APawn.
I’m using this class as a base for a blueprint, which I’ve tied to a mesh and put in the game world.
I’ve set the Pawn to be autoPossessed by player0.
I really have no idea how to get values from the input axes from the default PlayerController.
I’ve also tried setting Auto Receive Input to Enabled, but nothing seems to work

I’ve tried overriding PossessedBy

void ACode_PlayerController::PossessedBy(AController * NewController) {
	ThePC = Cast<APlayerController>(NewController);
}

and use:

ThePC->GetInputAxisValue("MoveForward");

but it’s always zero.

I’ve tried

this->GetController()->InputComponent->GetAxisKeyValue("MoveForward");

and

this->GetController()->InputComponent->GetAxisValue("MoveForward");

I’ve tried overriding SetupPlayerInputComponent, but for some reason I cannot type

InputComponent->BindAxis("MoveForward", this, &ADefaultPawn::MoveForward);

because I get a type error.

I’m at a loss.

SetupPlayerInputComponent()

Is not part of APawn class. You need to inherit from ACharacter if you want to override it. Or you need to implement it on your own.

How it is exactly done, you can check in source on GitHub.

The real question is why do you want to get Controller input in Pawn ? You should either make your input in pawn or in controller. If for some reason why want specific inputs different in some pawns, you should allow pawn to override PC input

Okay so I need to override from ACharacter first. How can I change the c++ baseclass of my Blueprint easily? I guess it’s not as easy as changing public : APawn to public : ACharacter…

On a related note: How do I remove a C++ class completely from the project? There are things generated, I’m not sure what to remove all together.

Inhering from ACharacter is also not the solution, because it spawns a default collider in the Blueprint editor.
I just want to make a costum Pawn that can be controlled by the player via C++. How hard can it be?!

Finally I’ve got it. Indeed “allow pawn to override PC input”, i.e. overriding APawn::CreatePlayerInputComponent (APawn::CreatePlayerInputComponent | Unreal Engine Documentation) and then posessing the pawn was the solution. Thanks.

How did you allow the pawn to override the Player Controller input?

Ditto. How did you “allow pawn to override PC input”?