Controlling the camera
The main camera has two different movements that the player can control: zooming in and out and panning vertically and horizontally. Although the player can perform both actions, there are limits defined by us, so any movement and zoom will display only assets and areas that the player can really see and interact with, hiding the edges of the world.
We are going to write a quite simple, yet flexible script to add a component to the main camera in the scene. The parameters exposed by the component in the Inspector window will make it easier to tweak and find the best values for each attribute.
So, create a new folder inside Scripts called Camera
, and create a new script there called CameraController.cs
. Now, first, we are going to define all the properties in this class, as shown in the following script (notice that although the properties are private, the [SerializeField]
attribute will expose them in the Inspector window so we can easily update the values...