i looked around here and i figured out how to have two cameras. But i couldnt find the code to switch them mid gameplay by pressing a key. everything was in java script. How do i do that?
public Camera camera1;
public Camera camera2;
public string whichCamera = "2";
// Use this for initialization
void Start () {
//camera1.camera.enabled = !camera1.camera.enabled;
}
// Update is called once per frame
void Update () {
if(whichCamera == "1")
{
print("i'm in 1");
camera1.GetComponent<Camera>().enabled = true;
camera2.GetComponent<Camera>().enabled = false;
}
if(whichCamera == "2")
{
print("i'm in 2");
camera1.GetComponent<Camera>().enabled = false;
camera2.GetComponent<Camera>().enabled = true;
}
}
}