T
T
Taranas2020-06-12 00:23:35
Unity
Taranas, 2020-06-12 00:23:35

How to set the boundaries of the camera movement along the boundaries of the background (sprite)?

Hello everybody!
I'm making a 2d game, with the ability to move the camera with swipes. I set the boundaries through Mathf.Clamp () so that the camera does not go beyond the sprite (background). But with a different screen resolution, the camera narrows and the specified boundaries become insufficient. A collider hangs on the background sprite, because clicks need to be read. I tried to take the size of the collider, but nothing good came of it.
I would like to know how you can get the correct borders for the camera at any screen resolution. It can be calculated through some formulas, depending on the resolution and size ..

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question