- Home /
Scale for 2d camera viewport?
Hi, I'm very new to Unity, so I apologize if this question is naive.
I'm starting a top down 2d game with a world made of rooms, and I'd like the camera to show one screen at a time, with discrete transitions between rooms. To achieve this, I have a Rect
associated to each room, holding the coordinates of the corners of the room in world space. On entering a room I call
Camera.main.rect = room.rect
.
This does set the camera's viewport, but the field of view of the camera is much larger than I want it to be - the camera's rect and the room's rect seem to be in incompatible units, and I'm not sure what the camera's units are. What's the correct way to go about this?
Answer by saulglasman0 · Jun 06, 2019 at 02:16 AM
I post a question and immediately figure it out. I believe the key is to set Camera.main.orthographicSize
.
Your answer
![](https://koobas.hobune.stream/wayback/20220612202709im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
2D Top Down Shooting Problem 1 Answer
Camera setup question 2 Answers
Cinemachine weird lines of color when moving? 1 Answer
How do I get rid of this motion blur? 0 Answers
2D Top-Down 3D-Like effect 2 Answers