Clamping camera for all resolutions

Updated on May 29, 2018 in [A] Unity Scripting
Share on Facebook0Tweet about this on TwitterShare on Google+0Share on Reddit0
1 on May 28, 2018

I currently have this script which uses Mathf.Clamp to restrict the camera movement on the X axis. However, it uses the cameras transform, which is not ideal. When the resolution changes, so does how far the camera can move.

How can I restrict the camera no matter what screen resolution is used?

  • Liked by
Reply
0 on May 29, 2018

Instead of hard coding the clamp values, set them at runtime using things like ViewportToWorldPoint

 

  • Liked by
Reply
Cancel