Hello
I have a game that is intended for mobile. I have used a fixed width script to lock the horizontal FOV so it always look the same horizontally but the vertical field of view changes. I would like for the vertical FOV to change only upwards and not in both directions (up and down).
I’ve included to pictures that show the difference between 9:16 and 9:18. I would like the bottom part of the screen to always be like on 9:16 while the top part of the screen can grow and show more of the sky box.


You can work out the difference between the two camera fieldOfView values.
float originalFieldOfView = 60; // This is set on the camera in the editor;
float currentFieldOfView = camera.fieldOfView; // Get the new value since your 'fixed width' code has adjusted it
float degreesDiff = currentFieldOfView - originalFieldOfView;
Transform t = camera.transform;
t.RotateAround(t.position, t.right, -degreesDiff/2);
If this rotates the wrong way then remove the minus sign on the last line.
Because I was suprised at the lack of answers around this sort of thing I’ve also thrown together a little project that you can find on GitHub here which is able to do this for you and comes with some editor scripts to hopefully guide the process a little easier.
For your use case you would want to set the Maintain View
value to width
or -1
and the vertical gravity
to top
or 1
.
Hope that helps.