# Orthographic Camera settings for a 2D game

I'm starting out a 2D wrestling game in Unity 5 and i need some help. The default resolution of game needs to be 320x240. The background sprite that i would be using is 640x480. The camera would move over the background to give it a hovering look. I want the Camera to cover exactly 320x240 resolution. I tried setting the Camera size to 1.2 and it looks approximate but i wanna be sure that the camera is exactly 320x240. By default all the images are set to 100 Pixels per Unit.

So my question is:

• How to set the camera to cover exactly 320x240
• Hello and welcome to gamedev stack exchange! Please limit your questions to a single question. I edited your question to remove your second question. Please create another question with your second question :) Questions? – Vaillancourt Jul 27 '15 at 15:47
• different question technically, but you want these answers gamedev.stackexchange.com/questions/75376/… – jhocking Jul 27 '15 at 18:55

I had the very same question while while starting out. Do take a look at the detailed answer I later posted. How does Unity size graphics

When we set camera size, there's a certain screen height. This height is fixed irrespective of the device screen. On larger devices, greater detail, on smaller devices, lesser detail. So, if I chose 760px as height of my background image, I calculate camera size as follows: cameraSize= (Height/2)/PixelsPerUnit which in my case is, (760/2)/100=3.8

Next, I need to make sure skybox doesn't show irrespective of the device's screen size. This means, design background for the widest aspect ratio which is 16:9. So, I calculated the width as

width=AspectRatio X height. Which in my case is (16/9) X 760=1352 px.

So my background is 1352 X 760 pixel. This fits 16:9 aspect ratio perfectly. On narrower ratios like 4:3, there is cropping towards the sides. But skybox never shows. Which was my main issue.

Set your Pixel per Unit to 1 and try witch this:

scale = Screen.height / nativeRes.y;
pixelsToUnit *= scale;
cam.orthographicSize = (Screen.height / 2.0f) / pixelsToUnit;


Where nativeRes is your default resolution. Attach it to MainCamera and now your orto size should fit automatically.

• But setting PPU to 1 would be bad for performance & physics right? Any solution with default value of PPU that is 100? – Jaspreet Singh Jul 27 '15 at 17:47
• If you work with pixelart just change FilterMode to Point and set format as a truecolor. Now your sprites should looks sharp. – MaD Jul 27 '15 at 20:19

Your orthographic camera size depends on the pixels per unit of your sprites.

Orthographic camera size is equal to 1/2 of the vertical units (meters if you use built in physics) you will see on the screen. Say size 6 means that your screen height will be 12 units.

The formula is: screen resolution / 2*orthographic size = pixels per unit on sprites