How can I change the camera's location using a derived PlayerCameraManager in c++?

Hi. I want to create my own third person, “Over the shoulder” camera logic.
I derived and implemented my own PlayerCameraManager class, and successfully was able to alter the rotation of my camera by overriding ProcessViewRotation. However, For the life of me, I cannot figure out how to actually move the camera. I want to be able to place the camera behind the player and look forward, but all my attempts have failed. What should I override / how can I alter the camera’s location?
All my attempts do not move the camera. The camera is just inside my character’s head. (I have the view target set to my controlled character pawn).

I really appreciate any assistance!

Try overriding:
virtual FVector GetCameraLocation() const;

Call the super of GetCameraLocation() and add your own offset.

Thanks for the response.

I am attempting that, by

FVector AMGSPlayerCameraManager::GetCameraLocation() const 
{
	UE_LOG(LogTemp, Warning, TEXT("%s"), *CurrentState->GetCameraOffset().ToString()); // test, nothing is logging!
	return Super::GetCameraLocation() + CurrentState->GetCameraOffset();
}

However, not even the UE_LOG is hit until I end the game for some reason. And the camera continues to be pinned to the player. I wonder if there might be something that needs to be set in the player controller or player camera manager.

I got it! I ended up overriding

void AMGSPlayerCameraManager::GetCameraViewPoint(FVector& OutCamLoc, FRotator& OutCamRot) const
{
	OutCamLoc += CurrentState->GetCameraOffset();
}

I appreciate your help!!!

1 Like