- Home /
Question by
AarshSinghVishen · Jan 30, 2017 at 07:35 AM ·
camera viewport
Keeping field of view the same in a 2d game
I am making a 2d game and i would like to keep the field of view the same for all aspect ratios. So far I've tried this: float windowAspect = (float)Screen.width / (float)Screen.height; float scaleHeight = windowAspect / targetAspect; Camera camera = GetComponent();
if (scaleHeight < 1.0f)
{
camera.orthographicSize = camera.orthographicSize / scaleHeight;
}
but it doesn't work. Any help is appreciated
Comment
Your answer
![](https://koobas.hobune.stream/wayback/20220612105856im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
How to set mini map camera to display entirety of the map 2 Answers
How to make the camera show only the part of the world which is in a specified rectangle? 0 Answers
Calculate camera position when angle is change but viewport bottom need to be fixed? 0 Answers
2D camera zoom out by the distance of player to an object, Zoom in when it gets further away 0 Answers
When playing a scene, Render LOD lines are visible? 0 Answers