- Home /
Question by
Montreal · Nov 15, 2018 at 03:31 AM ·
cameramathfcamera movementmathf.clamp
Limit camera pan not working
Hello, so i have this part of the script wich limits movement on x and y and it works on my 2d ortographic camera:
var pos = transform.position;
transform.position = new Vector2(
Mathf.Clamp(pos.x, xPanMax, xPanMin),
Mathf.Clamp(pos.y, yPanMax, yPanMin));
However when I change the screen size the limits are all off and I have to readjust the numbers for it not to leave the games boundaries or being able pan around the whole scene.
Is there any way to change this code so the limits stay the same even when chaning sizes/resolutions?
Thanks for the help.
Comment
Your answer
![](https://koobas.hobune.stream/wayback/20220612182148im_/https://answers.unity.com/themes/thub/images/avi.jpg)