How do I create a custom Movement Component for my Pawn player class?

Hello all, so here is my issue, and I’m hoping someone can point me in the right direction:

I have a custom player Pawn class with an imported Static Mesh. The reason I didn’t use a Character was because that needed a skeletal mesh and the player character doesn’t require that it’s a spaceship with 0 animations

The Blueprint for the player pawn looks good. I have a root component with a spring arm and camera plus the static mesh

The issue stems from my custom PlayerController class named PlayerShipController.cpp

Here is the .h file:


#pragma once

#include "CoreMinimal.h"
#include "GameFramework/PlayerController.h"
#include "PlayerShipController.generated.h"

UCLASS()
class SPACEGAME_API APlayerShipController : public APlayerController
{
GENERATED_BODY()

public:

APlayerShipController();

APawn* ControlledPawn;

virtual void SetupInputComponent() override;

void MoveUp();
void MoveDown();
void MoveLeft();
void MoveRight();
};

Here is the .cpp file


#include "GameFramework/Pawn.h"
#include "GameFramework/PawnMovementComponent.h"
#include "PlayerShipController.h"

APlayerShipController::APlayerShipController()
{
ControlledPawn = GetPawn();
ensure(ControlledPawn != nullptr);
}
void APlayerShipController::SetupInputComponent()
{
Super::SetupInputComponent(); //this line here keeps erroring out but I'm not sure why, is wasn't like that beforenot sure why

InputComponent->BindAction("Up", IE_Pressed, this, &APlayerShipController::MoveUp);
InputComponent->BindAction("Down", IE_Repeat, this, &APlayerShipController::MoveDown);
InputComponent->BindAction("Left", IE_Repeat, this, &APlayerShipController::MoveLeft);
InputComponent->BindAction("Right", IE_Repeat, this, &APlayerShipController::MoveRight);
}

void APlayerShipController::MoveUp()
{

UE_LOG(LogTemp, Warning, TEXT("MoveUP"));
ControlledPawn->GetMovementComponent()->AddInputVector(FVector(0.f, 0.f, 1.f));
}

There’s more to it but I cut it off at MoveUp, I have my other movement functions defined as well but they are empty (no issue since they are void)

So it looks like the GetMovementComponent does indeed return a UPawnMovementComponent but this is where I’m stuck because my custom controller class does work it does print the UE_LOG but it crashes right after and after doing some digging online it appears that I need to create my own MovementComponent too??? because Pawns don’t support one by default and it’s up to the programmer???

If that’s the case, how would I go about creating this? Is there any helpful resource that helps me create a basic one without any unnecessary bloat (what I mean by bloat is code specific to their particular use case) I wasn’t aware of this, and I’ve been running into so many hurdles with UE4 it’s insane. When I figure something out there’s yet another thing that smacks me in the face :confused: