Camera fov based on viewport size?

By default unreal constrain FOV to horizontal viewport width but this behaviour can be changed.

Variable can be changed from c++. I usually do it in Player Controller constructor

AHazardPlayerController::AHazardPlayerController(const FObjectInitializer& ObjectInitializer) : Super(ObjectInitializer)
{
    //HACK HACK 
    ULocalPlayer* DefaultLocalPlayer = ULocalPlayer::StaticClass()->GetDefaultObject<ULocalPlayer>();
    DefaultLocalPlayer->AspectRatioAxisConstraint = AspectRatio_MaintainYFOV;
}

Or you can add

[/Script/Engine.LocalPlayer]
AspectRatioAxisConstraint=AspectRatio_MaintainYFOV

to DefaultEngine.ini

3 Likes