How to Switch Between Cameras in Cinemachine

In no way similar to a face swap, we often want to switch camera shots in any form of media, games included. We could simply enable and disable the gameobjects, but within Cinemachine, our Virtual Cameras come equipped with a Priority variable, — the highest priority being selected.

Using game logic, we can access the gameobject itself, and use the SetActive modifier to turn the whole thing on and off. But with the Cinemachine Virtual Camera component, we can actually manipulate the different properties. For more advanced cases, we could write logic to alter priority values based on things like distance. But we can also simply hard code the status of each camera using the enabled modifier.

Note that this requires the Cinemachine library (using Cinemachine;) at the top of the script!

Using the code above to turn off two of the cameras, leaves us with one left standing. The cool thing about Cinemachine, is that it doesn’t necessarily hard cut. Instead, by default, the main camera smoothly transitions from position to position, but transition settings can also be adjusted if we wish!

Tomorrow we will look at how we can use just one camera to do various things with scripting.

--

--

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