In this guide I just want to quickly go over a simple way to switch between cameras in Unity. We can achieve this by setting different cameras on or off using SetActive().

We first start by deciding on the condition we use to change the camera. For now we’ll use Input buttons 1, 2 and 3 to switch between cameras. We go into Project Settings -> Input Manager and add three new items to the list, which we’ll label Switch1, Switch2, and Switch3. Each correspond to the button on the keyboard.

Image for post
Image for post

Then we write a C# script called CamSwitch. All we need is three public GameObjects which we’ll label cam1, cam2, and cam3 for each of the cameras we’ll be switching into. Inside the Update function, depending on which button we press, we’ll turn the corresponding camera active while setting the other cameras false. …

About

Fanzhong Zeng

Just a student at flatiron

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