Hello,
I found a number of threads about this though non of them seems to solve my problem. anywhoo I need to switch between two cameras by pressing a button, heres my script:
var combatCam : Camera;
var nonCombatCam : Camera;
function Start() {
// Sets nonCombatCam to a higher depth by default
// so at the start of the game the nonCombatCam is
// rendering.
nonCombatCam.depth = 1;
combatCam.depth = 0;
}
function Update() {
// If space is pressed and nonCombatCam
// is the highest depth (rendering), switch combatCam
// to highest depth and nonCombatCam to lowest
// depth, making the combatCam render instead.
//
// Else make combatCam the lowest depth and change
// nonCombatCam to highest depth so that it is rendering.
if(Input.GetKeyDown(KeyCode.Space)) {
if(nonCombatCam.depth == 1) {
nonCombatCam.depth = 0;
combatCam = 1;
}
else {
nonCombatCam.depth = 1;
combatCam = 0;
}
}
}
this will switch the depths on the cameras, where the camera with the highest depth is rendered and the others are not. Sorry for any discrepancies in the syntax, I’m a C# programmer.