- Home /
Enabling and siabling first person controller
I have 3 separate first person controllers set up in my scene and a cameraswitch script to switch between the three but the problem is that all 3 fps controllers move as well as shoot so targets in other rooms get destroyed. I'd like to know how I would enable an disable these using code. Here is my cameraswitch script.
pragma strict
var camOne : Camera;
var camTwo : Camera;
var camThree : Camera;
var switchOne : boolean = true;
var switchTwo : boolean = false;
var switchThree : boolean = false;
function Update () {
// If you hit the right click button it will switch to the different cameras in the different rooms.
if (Input.GetKeyDown(KeyCode.Mouse1)&& switchOne)
{
camOne.camera.enabled = true;
camTwo.camera.enabled = false;
camThree.camera.enabled = false;
camOne.camera.active = true;
camTwo.camera.active = false;
camThree.camera.active = false;
switchOne = false;
switchTwo = true;
switchThree = false;
}
else if (Input.GetKeyDown(KeyCode.Mouse1)&& switchTwo)
{
camOne.camera.enabled = false;
camTwo.camera.enabled = true;
camThree.camera.enabled = false;
camOne.camera.active = false;
camTwo.camera.active = true;
camThree.camera.active = false;
switchOne = false;
switchTwo = false;
switchThree = true;
}
else if (Input.GetKeyDown(KeyCode.Mouse1)&& switchThree)
{
camOne.camera.enabled = false;
camTwo.camera.enabled = false;
camThree.camera.enabled = true;
camOne.camera.active = false;
camTwo.camera.active = false;
camThree.camera.active = true;
switchOne = true;
switchTwo = false;
switchThree = false;
}
}
Your answer
Follow this Question
Related Questions
First Person Camera Not Spining Player 0 Answers
FPS Game Camera's switching when 2nd player shows 1 Answer
FPS Camera Position full Body 0 Answers
one camera or several? 1 Answer
Converting to 3rd Person from 1st Person - Island Demo 1 Answer