UE4 keeps the same field of view horizontal regardless of the width of the viewport. So a taller viewport will give the illusion of zooming out but in reality all it is doing is adjusting the horizontal frame to keep the save FOV. It is not really moving the camera or anything else.
Made this quick image to illustrate:
You can counter it using the Aspect Ratio (A.R.)to calculate the Field of View. For example:
- Take the formula for aspect ratio AR = HorizontalRes/VerticalRes → AR is a float.
- FOV is a const float defined by you.
Now we can do this using the numbers of the image above:
- AR * FOV = CameraFOV
So now our field of view will adjust like so:
So what this is telling us is it is 1.339 wider horizontally and even though the aspect ratio vertically is 0.74963, we want to limit it to 1.0 so we don’t go zooming in way more than we should. Know that we know this we can:
- For horizontal phone, a field of view of 90 → 1.3339 * 68.4713 = 90 and for a vertical phone → 1 * 68.4713 = 68.4713.
– You’ll need to clamp AR to a minimum of one so for when the height > width, the camera doesn’t keep lowering the FOV. - Where did 68.4713 come from?
– AR * FOV = CameraFOV → FOV = CameraFOV / AR
– 1.3339 * X = 90
– X = 90 / 1.3339
– X = 68.4713
To be clear: I have not done this specifically, but the math should work. I’ll test it out and share some blueprints later.
Hope this helps.