Easily Switch Between Cameras In Cinemachine

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:

And now we can add a Method called from Update that will assign the target transforms to the LookAt values of the Virtual Camera:

So now when we call our Method, we get this result, switching the Virtual Camera from the Cube to the Sphere:

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store