- Home /
First Person Camera switching
I am using the built in 1st person controller and am trying to script for a camera change from the player camera to a world map camera when I click a Gui texture, using this script:
var camera1 : Camera;
var camera2 : Camera;
function Start () {
camera1.enabled = true;
camera2.enabled = false;
}
function OnMouseUp () {
if (camera1.enabled == true){
camera1.enabled = false;
camera2.enabled = true;
}
if (camera2.enabled == true){
camera1.enabled = true;
camera2.enabled = false;
}
}
This is not working however. I am getting the world map view, but it does not change back to the player camera when I click the GUI button that the script is attached to again. I think it is because the first person camera is not disabling, but I am not sure. Please help.
Answer by pigi5 · Jan 16, 2011 at 11:56 PM
Nevermind, I looked at another persons script for a different thing and found that you can switch boolean variables using the ! character. I did that, and it works!
var camera1 : Camera; var camera2 : Camera;
function Start () { camera1.enabled = true; camera2.enabled = false; }
function OnMouseUp () { camera1.enabled = !camera1.enabled; camera2.enabled = !camera2.enabled; }
Your answer
Follow this Question
Related Questions
I need to remove the GUI from this camera script, but I don't know how. 2 Answers
Switch to second camera which has all the GUI 3 Answers
Switch Camera on Input in C# 3 Answers
Unity2D - Camera in exported game is zoomed out compared to unity game preview HELP PLEASE! 2 Answers
Puttings GUI's between objects 1 Answer