Richard Morgan

Here’s an easy way to switch cameras using triggers in Unity. Here’s the result:

We’ll use a GameObject called Managers to hold the CameraManager script that makes our array values available, and it will also hold our public functions that will update the priorities on the cameras as the triggers…

--

--

Here’s an easy way to add an interactive zoom to your Virtual Camera in Unity by ‘using Cinemachine’ GetComponent<CinemachineVirtualCamera>().m_Lens.FieldOfView.

Here we have a simple scene that includes a Virtual Camera, a Plane, an animated Cube and a Sphere:

Adding this script will allow us to update the Field Of View on the Virtual Camera:

--

--

Let’s explore how easy it is to switch between cameras using Cinemachine. We’ll start with a simple scene that includes a Virtual Camera, an animated cube and a sphere hovering above a plane:

We want a script that switches the camera from the animated cube to the sphere. So to do that, let’s use GetComponent<CinemachineVirtualCamera>().LookAt which we can access by ‘using Cinemachine’. We’ll create variables that hold a references to the Virtual Camera and the target objects:

--

--

Richard Morgan

Richard Morgan

Unity and Flutter developer interested in creating mixed-reality applications.