Change camera from FlyByCam to MainCamera

Hello!

I want to change my FlyByCam, which is obviously flying over an area, to change on left mouse button click to the MainCamera. I tried working with camera.main.Depth and stuff ike that but that didn’t seem to work. So I came up with this script from a similar other post. It just doesn’t seem to work. It won’t switch when I left click this way. I tried similar ways of figuring out on how to make it switch, but also putting it in Update just automatically puts it on MainCamera.

#pragma strict
var camera1 : Camera;
var camera2 : Camera;

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

To ask it more clearly:

Does anyone have a suggestion on how to switch from the FlyByCam to the MainCamera with only one left mouse button click?

Thanks in advance!

It would seem as if you have both cameras enabled. To easily switch between them make there be only camera active at a time. So if camera1 was the Fly By Camera and you wanted to switch to the Main Camera. You would disable camera1 and enable camera2. This should work.

I found the solution, for anyone that has the same problem:

var camera1 : Camera;
var camera2 : Camera;
 
function Start(){
    camera1.enabled = true;
    camera2.enabled = false;
}
 
function Update(){
    if(Input.anyKey){
            camera1.enabled = false;
            camera2.enabled = true;
        }
    }   

Make your camera1 the FlyByCam and camera2 the MainCam.

Done!