What if the screen size changes?

I can get the clamp value to something reasonable for a certain viewport size but when I preview the game in a different resolution the clamp value needs to be readjusted. Is there a way to make this playable on all resolutions?

Hi Greg,

You could use the Camera.ViewportToWorldPoint method. The viewport of the camera is normalised meaning that the bottom left corner is new Vector3(0f, 0f, 0f) and the top right corner new Vector3(1f, 1f, 0f).

See the API:
https://docs.unity3d.com/ScriptReference/Camera.ViewportToWorldPoint.html

This topic was automatically closed after 14 days. New replies are no longer allowed.

Privacy & Terms