Auto changing cameras

Im trying to get 3 cameras automatically change to the next camera after a set period of time on a constant loop so they can pan around an object whilst the game is inactive. A fade on these would also be nice but i have struggled with this too as i seem to only be able to get it to work between two cameras and it seems to fade straight back and forth. I worked on modifying the crossfade script to use time rather than the input.

So to change between cameras i have tried something like this… (where i can assign a different shot duration to each camera. Problem is i have them all under function update and this may be causing an issue. Its frustrating as i can understand why this might not work but i cant seem to get my head around a different way of doing it. Trying hard to learn code!)

var camera1 : GameObject;
var camera2 : GameObject;
var camera3 : GameObject;
var shotDuration1=25;
var shotDuration2=25;
var shotDuration3=25;

function Update () {

if (Time.time > shotDuration1){
camera1.camera.enabled = true;
camera2.camera.enabled = false;
camera3.camera.enabled = false;
}

if (Time.time > shotDuration2){
camera1.camera.enabled = false;
camera2.camera.enabled = true;
camera3.camera.enabled = false;
}

if (Time.time > shotDuration3){
camera1.camera.enabled = false;
camera2.camera.enabled = false;
camera3.camera.enabled = true;
}
}

I just need to get it to order correctly as i have had this working between to cameras but it has stopped working lol

Any direction would be much appreciated!

The simplest way would be to use Coroutines here in my opinion.

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

var shotDuration1=25;
var shotDuration2=25;
var shotDuration3=25;

function Update(){
    UpdateCameras();
}

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

    yield WaitForSeconds(shotDuration1);

    camera1.enabled = false;
    camera2.enabled = true;
    camera3.enabled = false;

    yield WaitForSeconds(shotDuration2);

    camera1.enabled = false;
     camera2.enabled = false;
     camera3.enabled = true;

    yield WaitForSeconds(shotDuration3);
}

You could also use an array of cameras to reduce the amount of code:

var cameras : Camera[];
var initialPause = 2.0;
var shotDuration = 2.0;
var index = 0;

function UpdateCamera(){
	cameras[index].enabled = false;
	index = (index+1) % cameras.Length;
	cameras[index].enabled = true;
}

function Awake(){
	InvokeRepeating("UpdateCamera", initialPause, shotDuration); 	
}

Make sure all but your starting camera are disabled on start.