- Home /
Do I need to enforce an aspect ratio for my 2D game
I'm working on a 2D game. I'm using an orthographic camera and the level is procedurally generated as a series of chunks (each chunk is basically a seperate room on a grid). I want the camera to snap to these chunks/rooms as the player moves between them (think Legend of Zelda: a Link to the Past). The camera movement logic is easy enough to implement. The problem comes when you have to take into account different devices/monitors.
Because I want the camera to always show the whole chunk/room and nothing beyond it, I'm thinking that I need to pick an aspect ratio, and enforce it using letter/pillarboxing. Is there a better way of doing this than potentially wasting screen space? Keep in mind, the camera has to show the exact width of the chunk. Setting the ortho height is fine for maintaning the sprites, but it doesn't help with potentially showing things that shouldn't be seen on wider monitors.
Let us get this straight: on wider monitors (or to better put it, monitors with a higher resolution) you want to keep the same sprite resolution (as opposed to creating larger, more detailed sprites). So, if your background sprite for a room is 300px wide, on a screen that is 300px wide it will cover the whole screen width, on a screen 900 pixel wide it will take less than a third of the width of the screen. And you are then asking what to do with the rest of the screen given that you don't want to show the nearby rooms?
$$anonymous$$aybe some more detail will help! The rooms of my game are made up of prebuilt layouts of individual tiles. The full level is made by stitching together these layouts to make random dungeons of connected rooms.
You're right that I don't want the camera to show the nearby rooms, only the room the player is currently in (I want to do it this way for several reasons, but most importantly things not in the current room are deactivated/recycled until needed for performance. You could get some ugly looking problems with tiles and objects disappearing etc. if you could see beyond the walls of the current room.
I'm currently working on the premise that one unit in world space = one tile. I'm not sure yet what the final resolution of the tiles will be I'll admit I haven't really thought about it much yet, currently I'm just using placeholder cubes for it all.
Thanks for the response!
Your answer
![](https://koobas.hobune.stream/wayback/20220613110541im_/https://answers.unity.com/themes/thub/images/avi.jpg)