- Home /
How can I change the orthographic camera’s viewport size based on aspect ratio?
I’ve designed my game based on a resolution of 800x1280; an aspect ratio of 5:8. I’m using an orthographic camera with a view of 640 (half of 1280).
If the game is run on a phone with a smaller aspect ratio (if the screen were more “narrow”), I’d like to increase the size of the orthographic camera’s viewport. I want this increase in size, however, to be proportional to the difference in aspect ratio, ie the difference between the reference ratio of 5:8 and whatever smaller aspect ratio the game is being run on.
The issue is in figuring out this proportionality… In other words, how do I find the dimensions that correspond to the smaller aspect ratio, in the same way that 800x1280 corresponds to 5:8???,I’ve designed my game based on a resolution of 800x1280; an aspect ratio of 5:8. I’m using an orthographic camera with a view of 640 (half of 1280). If the game is run on a phone with a smaller aspect ratio (if the screen were more “narrow”), I’d like to increase the size of the orthographic camera’s viewport. I want this increase in size, however, to be proportional to the difference in aspect ratio, ie the difference between the reference ratio of 5:8 and whatever smaller aspect ratio the game is being run on. The issue is in figuring out this proportionality… In other words, how do I find the dimensions that correspond to the smaller aspect ratio, in the same way that 800x1280 corresponds to 5:8???