- Home /
Question by
lucasfarleigh · Dec 08, 2016 at 06:46 AM ·
c#switch cameras
Camera Switch - Camera justs turns off, but does not switch
Hi, I am trying to make a camera switch and have looked at every video and thread, but I can still not do it. My situation is that I have this code attached and I dragged in two of my cameras . The script is attached on an empty. When I press Tab, it just says in runtime, not cutting to the other camera[display 3]
Display 2: No cameras rendering
I use this code:
using UnityEngine;
using System.Collections;
public class CameraController : MonoBehaviour {
//Define the camera
public Camera MainCamera;
public Camera SideCamera;
//Called every frame
void Update(){
if(Input.GetKey(KeyCode.Tab)){
MainCamera.enabled = false;
SideCamera.enabled = true;
}
}
}
What can I do? Thank you in advance.
Comment
Answer by lucasfarleigh · Dec 08, 2016 at 12:31 PM
I figured it out! If you switch cameras, you have to make sure that they are both on the same TARGET DISPLAY so both cameras have to be on display 2 for example. Hope that helps.