In this recipe, we will create a telescopic camera that zooms in whenever the left mouse button is pressed. This can be very useful, for instance, if we have a sniper in our game.
For this recipe, we have prepared the BasicScene
Unity package, containing a scene named BasicScene
. The package is in the 1362_05_codes
folder.
To create a telescopic camera, follow these steps:
Import the
BasicScene
package into a new Project.From the Project view, open the BasicScene level. This is a basic scene featuring an animated character and some extra geometry.
Import Unity's Effects package by navigating to Assets | Import Package | Effects.
Select the Main Camera GameObject within the Multipurpose Camera Rig | Pivot GameObject and apply the Vignette image effect (by navigating to Component | Image Effects | Camera | Vignette and Chromatic Aberration).
We need to create a script. In the Project view, click on the Create drop-down menu and choose C...