Zooming a telescopic camera

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.

Getting ready...

For this recipe, we have prepared the BasicScene Unity package, containing a scene named BasicScene. The package is in the 1362_05_codes folder.

How to do it...

To create a telescopic camera, follow these steps:

  1. Import the BasicScene package into a new Project.
  2. From the Project view, open the BasicScene level. This is a basic scene featuring an animated character and some extra geometry.
  3. Import Unity's Effects package by navigating to Assets | Import Package | Effects.
  4. Select the Main Camera GameObject within the Multipurpose Camera ...

Get Unity 5.x Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.