Reassign camera movements with PlayerController

OK, so I cant get I rebinded all keys in UE4 so the default free camera movement is now gone, however I’m trying to recreate it with my player controller class but with no success. I’ve tried many different ways and all failed, don’t see much when i search google.



#include "MyProject.h"
#include "MyPlayerController.h"
#include "MyPlayerCameraManager.h"

AMyPlayerController::AMyPlayerController()
{
	this->myListing = new struct myKeyList;
	PlayerCameraManagerClass = AMyPlayerCameraManager::StaticClass();
	this->checkVal = false;
}

void AMyPlayerController::PlayerTick(float deltaTime)
{
	Super::PlayerTick(deltaTime);

	if (this->checkVal == true)
	{
		FVector cPos = this->camera->GetActorLocation();
		cPos.X += 1000 * deltaTime;
		this->camera->SetActorRelativeLocation(cPos, false, nullptr, ETeleportType::None);
	}
}

void AMyPlayerController::SetupInputComponent()
{
	Super::SetupInputComponent();

	check(InputComponent);
	UE_LOG(LogTemp, Warning, TEXT("Controller output."));
	/*InputComponent->BindKey(EKeys::BackSpace, IE_Pressed, this, &AMyPlayerController::displayMSG1);
	InputComponent->BindKey(EKeys::BackSpace, IE_Released, this, &AMyPlayerController::displayMSG2);*/
	InputComponent->BindAxisKey(EKeys::MouseX, this, &AMyPlayerController::myMouseYaw);
	InputComponent->BindAxisKey(EKeys::MouseY, this, &AMyPlayerController::myMousePitch);
	this->InitmyKeys();
}

void AMyPlayerController::BeginPlay(void)
{
	Super::BeginPlay();

	/*this->thisCamera = this->GetViewTarget();
	this->camera = Cast<ACameraActor>(this->thisCamera);*/
	AMyPlayerCameraManager* camera = Cast<AMyPlayerCameraManager>(UGameplayStatics::GetPlayerCameraManager(GetWorld(), 0));
	if (camera)
	{
		UE_LOG(LogTemp, Warning, TEXT("Camera found."));
	}
}

void AMyPlayerController::displayMSG1(void)
{
	UE_LOG(LogTemp, Warning, TEXT("debug msg1."));
	GEngine->AddOnScreenDebugMessage(-1, 5.0f, FColor::Red, TEXT("Key Recognized."));
	//&AMyPlayerCameraManager::moveForward(1.0);
	this->checkVal = true;
}

void AMyPlayerController::displayMSG2(void)
{
	UE_LOG(LogTemp, Warning, TEXT("debug msg2."));
	GEngine->AddOnScreenDebugMessage(0, 5.0f, FColor::Yellow, TEXT("Key Released."));
	this->checkVal = false;
}

void AMyPlayerController::myMouseYaw(float value)
{
	AddYawInput(value);
	//UE_LOG(LogTemp, Warning, TEXT("debug msg3, value = %.2f"), value);
	GEngine->AddOnScreenDebugMessage(1, 5.0f, FColor::Blue, TEXT("Mouse Yaw Detected."));
}

void AMyPlayerController::myMousePitch(float value)
{
	AddPitchInput(value * -1);
	//UE_LOG(LogTemp, Warning, TEXT("debug msg4, value = %.2f"), value);
	GEngine->AddOnScreenDebugMessage(2, 5.0f, FColor::Blue, TEXT("Mouse Pitch Detected."));
}

void AMyPlayerController::InitmyKeys(void)
{
	int i;

	UE_LOG(LogTemp, Warning, TEXT("Binding all keys.."));
	for (int x = 0; x < 5; x++)
	{
		i = 0;
		while (this->myListing->c[x]* != EKeys::AnyKey)
		{
			InputComponent->BindKey(this->myListing->c[x]*, IE_Pressed, this, &AMyPlayerController::displayMSG1);
			InputComponent->BindKey(this->myListing->c[x]*, IE_Released, this, &AMyPlayerController::displayMSG2);
			i++;
		}
	}
}




#include "MyProject.h"
#include "MyPlayerCameraManager.h"

AMyPlayerCameraManager::AMyPlayerCameraManager()
{
	this->movement = false;
}

void AMyPlayerCameraManager::UpdateCamera(float deltaTime)
{
	Super::UpdateCamera(deltaTime);

	if (this->movement)
	{
		this->cPos = GetCameraLocation();
		cPos.X += 100 * deltaTime;
		SetActorLocation(cPos);
	}
}

void AMyPlayerCameraManager::InitializeFor(APlayerController * PC)
{
	Super::InitializeFor(PC);
	UE_LOG(LogTemp, Warning, TEXT("Camera log"));
}

void AMyPlayerCameraManager::moveForward(void)
{
	this->movement = true;
}

void AMyPlayerCameraManager::stopAllMovement(void)
{
	this->movement = false;
}


i think you need to create one in your character/controller constructor.