It’s pretty easy to setup an Orthographic Camera in Unity, but without paying attention the settings can cause us numerous problems when it comes to sprites, textures and the quest for pixel perfect graphics in our games.
When wanting pixel perfect graphics it is important that we set the camera size to give us a 1:1 pixel/texture ration between Photoshop (or your alternative) and Unity.
For example, if our game resolution is set to width = 960px height = 640px and our camera size is set to 5 a Unity cube (scaled at 1,1,1) will be the equivalent of a 64px by 64px square in Photoshop. This means that our game screen will have space for ten 64px sprites stacked on top of each other.
Many game devs will prefer to work with a set size in Photoshop and then adjust their camera setup in Unity accordingly. Depending on the resolution and the target Photoshop size this can require some complicated trial and error. However an untraceable contributor in the comments section of Rocket 5’s wonderful tutorial series on 2D in Unity , provided a formula thus avoiding the trial and error.
Camera Size = x / ((( x / y ) * 2 ) * s )
x = Screen Width (px)
y = Screen Height (px)
s = Desired Height of Photoshop Square (px)
It’s a formula that works perfectly and I have setup a calculator to make the calculation process even easier via my Pixel Perfect Camera Size Calculator – Google Doc. Feel free to share, use and download as you wish.
An orthographic camera is commonly used when designing 2D games within Unity and setting up an orthographic camera is pretty simple:
Step 1 : Set position to x=0, y=0 and z = -10 (any depth that you choose depending on the Z values of your game objects).
Step 2 : Rotation to x=0, y=0 and z=0
Step 3 : Scale to x=1, y=1 and z=1
Step 4 : Change the ‘Projection’ drop-down to Orthographic (default is Perspective).
Step 5 : Set Camera size to 5 (this number can vary – with my game resolution a size of 5 worked).
Step 6 : Create some objects (I added three simple cubes) and change Ambient Light to light grey via Edit > Render Settings > Inspector > Ambient Light (colour chooser). You can use any light colour or if you prefer stick to the default black ambient light and add some lights to the scene.
I have been reading up on game development and trying to select the tools that will help me design on the Ouya. After much investigation and reflection I have decided to learn the Unity 3D platform as its one powerful beast, has a excellent community, good tutorials and its scalable for small and big projects.
I have also downloaded Blender as it’s free, has a vibrant community online but also powerful enough to take care of all of my modelling needs.
Now I need some tutorials to get stuck into to understand Unity 3D a little more!