Is there a way to be able to access and change a camera/camera component's FOV using C++?

Is there a way to be able to access and change a camera/camera component’s field of view (FOV) using C++? I already used APlayerController::FOV but won’t work.

I have a pawn with a camera component:

image

You can lock in specific FOV with PlayerController->PlayerCameraManager->SetFOV(120).

If FOV is not locked it should use FOV as defined in camera component. In that case you need to access the camera component and set fov there, eg.
PlayerController->GetPawn()->FindComponentByClass<UCameraComponent>()->SetFieldOfView(120)

1 Like

Thank you, it helped! Here’s how I did it:

if (UWorld* World = GetWorld())
{
		APlayerCameraManager* PlayerCamera = World->GetFirstPlayerController()->PlayerCameraManager;
		CameraFOV += 40.0f;
		PlayerCamera->SetFOV(CameraFOV);
		GEngine->AddOnScreenDebugMessage(-1, 15.0f, FColor::Yellow, FString::Printf(TEXT("Increased FOV to: %f"), CameraFOV));
}

where the CameraFOV has an initial value.