- Home /
Fixing the camera's left side in a 2D Game in all screen resolutions
I just started making a 2D game using unity and I have a resolution & cam problem. I have a 2D terrain and i'm trying to fix the left side of the cam to the left side of the terrain. However, when I change the screen resolution to iphone 4 for example, the left side is hidden. I tried this script for the cam but it's not working :
void Awake()
{
Ray ray = Camera.main.ScreenPointToRay(new Vector3(Screen.width/ 2, Screen.height / 2,-10));
Camera.main.orthographicSize = ray.origin.y;
transform.position = new Vector3 (ray.origin.x, ray.origin.y,-10);
}
Comment
Your answer
Follow this Question
Related Questions
How to letterbox the screen and have pixel perfection in a 2d game 0 Answers
2D Game. Screen, Camera and coordinates. 0 Answers
The New 2D Pixel Perfect Camera Package "Stretch Fill" Causes Major Lag 0 Answers
Choppy camera follow. 1 Answer
Top-Down 2D game:How to make the camera move on hitting the sides of the screen? 2 Answers