- Home /
How to position game objects in different screen resolutions?
I have designed my game on 1280 x 800 screen. I have positioned objects on the screen using screen width and height as a reference, say 30% from left etc.
when i run the game on lower resolutions the objects are not in correct places. I thought that in small resolutions it will work automatically.
What is the standard methods used to display properly on all screen sizes?
I have a Orthographic camera setup. for 1280 x 800 screen size i have the size at 400
I didn’t do anything special, I used following code to place object right side of the screen
gameObject.transform.position = new Vector3(Screen.width,gameObject.transform.position.y,gameObject.transform.position.z);
and following for the camera, to center it
float usingHeight = Screen.height;
float usingWidth = Screen.width;
//camera.orthographicSize = usingHeight/2;
camera.transform.position = new Vector3(usingWidth/2,usingHeight/2,0.0f);
in 1280 x 800 the object get placed nicely at the right edge, lower resolution they do not. But the objects size seems to be correct for say 480x320.
if I set the orthographicSize it might work, I don’t know how to calculate it properly