camera switching

This script is not working.

function OnTriggerEnter (col : Collider) 
{
    camera.main.active = false;
     animation.Play("heli");
    camera.main.active = true;
}

The script disables the camera but does not enable it afterwards.

format your code properly and don't demand help asap, if you are that desperate look up the script you are using and learn to fix it yourself.

i think marowi is right edited post to conform

2 Answers

2
    function OnTriggerEnter (col : Collider)
{
   DoStuff();
}

function DoStuff()
        { 
              animation.Play("heli")
              camera.main.active = false; 
              yield WaitForSeconds (AnimationLength);
              camera.main.active = true; 
        }

I have written a script to switch between any no of camera’s

/****************************


  1. Attach this script to any game object
  2. In the inspector window set the no of camera’s you have in Camera’s Variable
  3. Drag the camera’s game objects and you are done


*****************************/

var cameras:GameObject;

private var camId:int = 0;

function Update () {
if(Input.GetKeyDown(“c”)){
switchCamera();
}
}

function switchCamera(){
camId++;
if(camId < cameras.Length){
cameras[camId-1].gameObject.active = false;
}
else{
camId = 0;
cameras[cameras.Length-1].gameObject.active = false;
}
cameras[camId].gameObject.active = true;
}