- Home /
Question by
adisharma897 · Jun 07, 2019 at 07:32 AM ·
c#androidcamerarendering
No Camera Rendering when switching between cameras developing for Android
Hiii. I am a newbie in Unity. I am trying to develop a game for Android. I am trying to switch between cameras when a certain condition is fulfilled. It is showing No Camera Rendering when the switch takes place.
I have a player with Rigidbody attached to it. I have two Cameras- Main Camera and Side Camera both having the tag "Main Camera".
public class CameraSwitch : MonoBehaviour
{
public Camera MainCamera;
public Camera SideCamera;
public GameObject Player;
private Rigidbody rb;
void Start()
{
rb = Player.GetComponent<Rigidbody>();
MainCamera.gameObject.SetActive(true);
SideCamera.gameObject.SetActive(false);
}
void Update()
{
if (Player.transform.position.z > 300f & rb.velocity.z <= 0.2f)
{
SideCamera.gameObject.SetActive(true);
MainCamera.gameObject.SetActive(false);
}
}
}
I even tried the MainCamera.enabled=false thing.
public class CameraSwitch : MonoBehaviour
{
public Camera MainCamera;
public Camera SideCamera;
public GameObject Player;
private Rigidbody rb;
void Start()
{
rb = Player.GetComponent<Rigidbody>();
MainCamera.enabled= true;
SideCamera.enabled= false;
}
void Update()
{
if (Player.transform.position.z > 300f & rb.velocity.z <= 0.2f)
{
SideCamera.enabled= true;
MainCamera.enabled= false;
}
}
}
Main Camera
Side Camera
main-camera.jpg
(68.5 kB)
side-camera.jpg
(65.2 kB)
Comment