# Placing a Camera In World (Screen Resolution)

This topic is 2932 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hello,

I am designing a game for mobile devices. I am trying to come up with a formula that will allow me to place the main camera in the world so that what it sees will look the same on different screen resolutions.

Essentially, I have a cube which has a fixed width, height and depth which sits on the origin. I need the camera to look on one side of the cube which is actually a room in my game. There is no rotation on the camera and it looks straight ahead at the cube. At the moment I set the Y axis of the camera so that it is half the height of the cube (i.e. 25.0f). I need to know how to calculate how far back to place it on the Z axis so that the face of the cube fills the screen at different screen resolutions.

Please see the linked picture below for a rough visual attempt at the problem:

http://i1213.photobu...meraProblem.jpg

I would like to minimise any borders down the left and right of the screen if possible.

Is someone mathmatically inclined able to help me out ?

##### Share on other sites
Thats a bit of an issue a friend of mine has been working on for the past year(?) or so. He's been building a 2D engine for mobile platforms and had similar problems regarding the viewport. You can take a look at his implementation here: http://yoghurtgum.googlecode.com/svn/trunk/Source/Modules/RenderMethodDirectDraw/src/ViewportDirectDraw.cpp

But the problem is that if you have a solution for one type of screen / resolution its not always going to work for every single one. There are many solutions for all different problems. So good luck on this one, think you'll have to trial-and-error most of it yourself

• ### Game Developer Survey

We are looking for qualified game developers to participate in a 10-minute online survey. Qualified participants will be offered a \$15 incentive for your time and insights. Click here to start!

• 12
• 30
• 9
• 16
• 12