- Home /
Sniper zoom when right click?
How can i make it so when i hold the right click on the mouse with my sniper it zooms in like 5x? any scripts or tutorials will help.
Also i need to know how to build the whole thing... i tired
function zoom () {
if (Input.GetKeyDown("z")) { Camera.main.fieldOfView = 10; } } . . . . . . . . . . . . . . . . . . . . . . . . . . .. . . . . .but i didn't work and i don't know the name for right click any way?
ok, i added a function to show the use, see the script below in my original reply.
Answer by jonas-echterhoff · Jun 23, 2010 at 08:37 AM
In a script, simply change the camera's field of view to a low angle, like this:
private var baseFOV : float;
function Start () { baseFOV = Camera.main.fieldOfView; }
function Update () { if (Input.GetMouseButton(1)) Camera.main.fieldOfView = 10; else Camera.main.fieldOfView = baseFOV; }
Thank you!! this is one of the best answers ive ever seen... it was so simple! but do you know how to make it so the sensitivity changes and so that the crosshair changes?
Also (sorry i'm asking so much) how do you make it toggle on or off.
if (Input.Get$$anonymous$$ouse(1)) Camera.main.fieldOfView = 10; else Camera.main.fieldOfView = baseFOV;
I believe that would work. Or you can create a bool for the toggle.
if (Input.Get$$anonymous$$ouseButton(1))
if (toggle == true)
{
toggle = false;
Camera.main.fieldOfView = baseFOV;
}
else
{
Camera.main.fieldOfView = 10;
toggle == true;
}
Your answer
Follow this Question
Related Questions
How to add sniper zoom effect in an FPS made with Unity3d? 2 Answers
FPS sniper zoom effect without black texture? 3 Answers
Sniper Demo: When zoom the raycast change its aim ! 0 Answers
Sniper Scope? 1 Answer
How to make my gun semi-auto? 1 Answer