- Home /
Mouse Question
I have a script that makes it change camera when I right click
var cameraMain : Camera;
var camera3rd : Camera;
function Start () {
cameraMain.enabled = true;
camera3rd.enabled = false;
}
function Update () {
if (Input.GetMouseButtonDown(1)){
if ( cameraMain.enabled == true){
camera3rd.enabled = true;
cameraMain.enabled = false;
}
else if (camera3rd.enabled == true){
cameraMain.enabled = true;
camera3rd.enabled = false;
}
}
}
But I want it to change when the right button is being held down and I want it to go back to cameraMain when it is released.
Comment
Best Answer
Answer by T27M · Feb 06, 2013 at 01:53 AM
You need to use the GetMouseButton() which returns true while the mouse button is held down.
function Update ()
{
if(Input.GetMouseButton(1))
{
camera3rd.enabled = true;
cameraMain.enabled = false;
}
else
{
cameraMain.enabled = true;
camera3rd.enabled = false;
}
}
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Help In Making a SphereCast for 3D Tire! Working RayCast Script included! 0 Answers
Why is my camera switching angles? 0 Answers
After transform position player is stuck 1 Answer
Character Controller Help. 1 Answer