How to change main game camera?

How can I change which camera is the main game camera on the fly in a script? I’ve searched all over for a way!

Thanks in advance!

really simple you can do this by creating a script simular to this(script below check for syntax errors.

you will also have to make the second camera unactive when scene starts otherwise you will get a error sayin 2 audio listeners in the world blah blah

var CAMERA1 GameObject;
var CAMERA2 GameObject;


function Update () {
CAMERA1. gameobject.active = false
CAMERA2. gameobject.active = true
}

really simple you can do this by creating a script simular 2 this(script below check for syntax errors.

you will also have to make the second camera unactive when scene starts otherwise yu will get a error sayin to audio listeners in the world blah blah

var CAMERA1 GameObject;
var CAMERA2 GameObject;


function Update () {
camera1. gameobject.active = false
camer2. gameobject.active = true

And you’ll have twice the draw calls if you don’t deactivate the other camera :wink:
I got through the same problem a few days ago.

If you deactivate the other camera properly it’s not really much of a problem but it’s also good to know about the camera layer depth:

Ah, I thought there might have been a cleaner way. Thanks for the help!