2D platform game stop camera from moving once reach end of screen

I’m trying to create a 2d platform game were the camera moves from left to right. I want the camera to stop moving when it reaches the end of the level. I tried stopping the camera when it’s greater than or equal to the coordinates that I need. And it works! But if I try my game on different monitors/resolutions you get black space at the end of the level. (It doesn’t stop when I want it to stop.) So is there a way to, no matter the resolution of the screen, stop the camera from moving?

Thanks for your help! :smiley:

With an orthographic camera, the orthographicSize is 1/2 of the vertical height the camera sees. You can calculate the half width with:

var halfWidth = Camera.main.orthographicSize * Screen.width / Screen.height;

The ‘halfWidth’ is how far (x axis) before the end of your level you need to stop.