How do I go about switching between camera’s because I am having trouble finding a example or idea in the unity script. I have a idea but I am not sure it will work so I post this now and if it does I will update with a nvm but until then I got no idea XD
var cameraOne : Camera;
var cameraTwo : Camera;
var curCam : int = 0;
function Update() {
if (Input.GetKeyDown(KeyCode.Space)) {
if (curCam == 0) {
curCam = 1;
cameraOne.enabled = false;
cameraTwo.enabled = true;
}
else {
curCam = 0;
cameraOne.enabled = true;
cameraTwo.enabled = false;
}
}
}
A simple enough example! You switch cameras using the spacebar. As with all Unity variables, you’ll have to drag the cameras involved onto the variables inside the editor first.
basically which ever camera I want to view needs enabled and the rest are disabled correct ?
yep, unless you need to render several cameras simultaneoulsy (dividing your screen into parts).
I have done this however it just becomes a gray screen and doesnt actually enable or disable… is there a reason for this?
var marble : GameObject;
var splashParticle : GameObject;
var splashSound : AudioClip;
var camera1 : Camera;
var camera2 : Camera;
function OnTriggerEnter(trig : Collider) {
var closestPoint : Vector3 = collider.ClosestPointOnBounds(trig.transform.position);
Instantiate(splashParticle, closestPoint, Quaternion.Euler(-90,0,0));
audio.PlayOneShot(splashSound);
var other : Component;
other = marble.GetComponent("Movement");
other.enabled = false;
camera1.enabled = false;
camera2.enabled = true;
}