Switch Camera (492190)

Hello,
Im using this coding for switching cameras but only the main works. if i change the character freezes. Any ideas why?

var camera1 : Camera;
var camera2 : Camera;
var camera3 : Camera;

function Start () {
camera1.enabled = true;
camera2.enabled = false;
camera3.enabled = false;
}

function Update () {
if (Input.GetKeyDown (“1”)){
camera1.enabled = true;
camera2.enabled = false;
camera3.enabled = false;

}

if (Input.GetKeyDown (“2”)){
camera1.enabled = false;
camera2.enabled = true;
camera3.enabled = false;
}

if (Input.GetKeyDown (“3”)){
camera1.enabled = false;
camera2.enabled = false;
camera3.enabled = true;
}
}

You may be able to fix it with GetKey or GetKeyUp instead of GetKeyDown.

My guess is that you have code to control the character on one of the cameras but not on the other 2. Either that or your character control code references Camera.main directly.

You have to set each camera tag as the main camera in the editor. It only works with the main camera because it’s the only one tagged as a main camera.