1/1/17

Script to change cameras in diferent zones

Well, this little Script is make to switch between different cameras on pasing for differents triggers.



First create one collider to be trigger (with rigidbody), and inside put a camera



to these collider put this script

var camara1 : GameObject; // Main Camera
var camara2 : GameObject; // Camera to change

/* // if there are more cameras right next to te main
var camara3 : GameObject;
var camara4 : GameObject;
var camara5 : GameObject;
*/

function Start () {

}

function OnTriggerEnter (otro : Collider) {
if(otro.tag == "player"){ //if the player enter in the trigger
camara1.SetActive(true); // active the camera of the object
camara2.SetActive(false); // desactive the previus camera
/*
if(camara3)
camara3.SetActive(false);
if(camara4)
camara4.SetActive(false);
if(camara5)
camara5.SetActive(false);
*/
}
}


Duplicate the object and posicione the cameras, desactive the second camera.




When you go through the cubes, you will see how they change the camera

That was it n_n

No comments:

Post a Comment