- Home /
How to change the sensitivity on right click (when zoomed in)
I have acript to zoom in the camra but i want it to zoom in faster and change the sensitivity when zoomed in because it is to fast( because the cam has smaller field of view) if you can fix please tell me how!
Script:
private var baseFOV : float;
function Start () {
baseFOV = Camera.main.fieldOfView;
}
function Update () {
if (Input.GetMouseButton(1))
Camera.main.fieldOfView = Mathf.Lerp(Camera.main.fieldOfView,35,Time.deltaTime);
else
Camera.main.fieldOfView = Mathf.Lerp(Camera.main.fieldOfView,baseFOV,Time.deltaTime);
}
Answer by DeveshPandey · Nov 28, 2012 at 07:12 AM
I remember that this was my answer. :)
Anyway try this, change the speed variable and enjoy :)
private var baseFOV : float;
private var speed : float = 25f;
function Start () {
baseFOV = Camera.main.fieldOfView;
}
function Update () {
if (Input.GetMouseButton(1))
Camera.main.fieldOfView = Mathf.Lerp(Camera.main.fieldOfView,35,Time.deltaTime*speed);
else
Camera.main.fieldOfView = Mathf.Lerp(Camera.main.fieldOfView,baseFOV,Time.deltaTime*speed);
}
O$$anonymous$$, no problem. if this works then mark as accepted and thumb up, Thanks!
One more question, how do u change the senitivity wile zoomed in?
not getting you, tell me clearly what you want to do? Sorry for my bad English. :)
When I right click it zooms in right but when I do that it changes the cameras field of view. doing this makes it seem like the sensitivity is high, is there a way to lower this while zoomed in (Right Click)?
Answer by Flynn · Nov 28, 2012 at 07:04 AM
Using AOV instead of FOV might help!
public var minFOV : float = 1;
public var baseFOV : float = 0;
public var czoom : float = 0;
function Start ()
{
baseFOV = Camera.main.fieldOfView;
}
function Update ()
{
//Step one: Calculate the percentage of the maximum zoom that should be used (this is actually the perscentage of the maximum AOV (area of view)
if (Input.GetMouseButton(1))
czoom = Mathf.Lerp(czoom, 0.0, Time.deltaTime);
else
czoom = Mathf.Lerp(czoom, 1.0, Time.deltaTime);
//Step two: Calculate the wanted Aov from our zoom percentage
var maxAov : float = FOVtoAOV(baseFOV, Camera.main);
var minAov : float = FOVtoAOV(minFOV, Camera.main);
var aov : float = Mathf.Lerp(minAov, maxAov, czoom);
//Step three: Calculate the corresponding FOV for our wanted AOV
var fov : float = AOVtoFOV(aov, Camera.main);
//Step four: Apply the fov!
Camera.main.fieldOfView = fov;
}
function FOVtoAOV(fov : float, cam : Camera)
{
return (fov/90.0) * cam.farClipPlane;
//At 90 degrees the width of the AOV will be directly proportional to the distance of the camera
}
function AOVtoFOV(aov : float, cam : Camera)
{
return (aov/cam.farClipPlane)*90.0;
//When our AOV equals the farClipPlane, the FOV will be 90 degrees
}
Let me know how this works! :) You may have to fine tune the speeds as it does zoom out rather quickly -- but zoom speed slows down as you get to smaller zoom : D
It zooms rather slowly and FOREVER but other wise it's great!
Change czoom = $$anonymous$$athf.Lerp(czoom, 0.0, Time.deltaTime); to czoom = $$anonymous$$athf.Lerp(czoom, 0.0, Time.deltaTime * yourspeed); to adjust the zoom in and zoom out speeds :)
Your answer
Follow this Question
Related Questions
gun scope cam not working 3 Answers
Modern Warfare Styled Zoom? (Javascript issue) 0 Answers
Shooting system not working 1 Answer
FPS sniper zoom effect without black texture? 3 Answers
Restricting camera movement in first person camera? 0 Answers