Proper Way to Rotate Camera?

I’m trying to implement a simple lean feature in my game and all I want to do is find wherever the camera rotation is calculated and add a little angular offset to the roll factor.

I’m working off of the SampleShooter project from the Marketplace. The first thing I tried was going into the PlayerController’s CalcCamera function but it never seems to be called, which I’m assuming is because it’s letting the PlayerCameraManager take over (or something? I’m not sure, this is one of many examples of the API documentation being a bit vague or detached from what actually is taking place in the engine.)

So all I’m asking is what the proper way is to modify the active camera’s location/angles. Thanks!

Hi, i don’t know if it helps but in Unity i “stuck” the Camera on a skeleton of some Bones and achieved Hollywood like camera crane moves…

Thanks but I’m more concerned with figuring out how Unreal handles cameras and why CalcCamera is never being called on the PlayerController.

Nobody knows how to modify camera position/rotation?

This seems pretty basic, would appreciate a response from Epic or someone with more experience seeing how simple this answer should be.

Just give it some more time, I’m sure someone will come along to answer. I also really wanted to say that I absolutely love your avatar picture, what is that from?

The camera rotation and positioning are set in the CameraComponent::GetCameraView function. This is a bit of one that I am using for the game Exodus:

void UExodusCameraComponent::GetCameraView(float DeltaTime, FMinimalViewInfo& OutResult)
{
	APlayerController* Controller = GetPlayerController();
	if (Controller)
	{
		OutResult.FOV = 30.f;
		const float CurrentOffset = MinCameraOffset + ZoomAlpha * (MaxCameraOffset - MinCameraOffset);

		FVector Pos2 = Controller->GetFocalLocation();
		OutResult.Location = Controller->GetFocalLocation() - FixedCameraAngle.Vector() * CurrentOffset;
		OutResult.Rotation = FRotator::MakeFromEuler(FVector(0, -90, 0));
	}
}

The rotation and location are returned through the FMinimalViewInfo structure to the calling method. You can overwrite and or use this code as you see fit.

Also, If you take the liberty of reading the documentation from Epic, you will see the responsibility chain for modifying the camera positioning and orientation. That should help you identify your issue. You may also find looking at the shooter and or strategy game samples useful, as they are both making modifications to the camera and its positioning.

Thanks for the reply. I’ve read the camera responsibility chain few times over before posting this, my issues are that my PlayerController is never calling CalcCamera and I cannot locate a CameraComponent anywhere.

I’ve searched in the PlayerController, the Character/Pawn and the PlayerCameraManager and haven’t been able to figure out where the CameraComponent is actually held, if you could tell me that I would greatly appreciate it!

Thanks! I’m not entirely sure, I think I nabbed it off Tumblr a long time ago to be honest. You could reverse image search it if you really wanted it!

Hi, I’ve been struggling with this myself.

CalcCamera is not automatically called on your custom player controller.

In the BeginPlay() method on your custom player controller set the view target like so :

this->SetViewTarget(this);

Do that and your code in the PC CalcCamera method will be called.

Hope that helps!

Worst case, if reefG’s solution doesn’t help you join me on IRC and ill do my best to help you chase down the issue.

Thanks, this answer helped me figure it out, I overrode the UpdateViewTarget method of the PlayerCameraManager and that gave me the intended result. Thanks to reefG and Bob_Gneu for the help.

Hi kopirat, could you post the details how to handle this issue? I wanna do the same thing here… thanks a lot…