- Home /
Toggle camera sensitivity
So here's what I'm adding to a JavaScript version of MouseLook:
if (Input.GetButton("Zoom"))
{
sensitivityX = 1;
sensitivityY = 1;
}
How do I make this so that it toggles on and off?
Answer by Kacer · Jun 06, 2011 at 07:57 AM
if(Input.GetButton("Zoom")){
sensivityX = 1;
sensivityY = 1;
}else{
sensivityX = 10;
sensivityY = 10;
}
is this what you mean?
if you're pressing the zoom button you've got a sensivity of 1, when you arent pressing it, its got a sensivity of 10 :)
Edit:
im just gonna make this in C# as i cant remember the syntax for javascript, i'll try to explain what i do though, also there might be an easier way to do it, but this is how i would do it ;)
//make a boolean that will tell you if you're using low sensivity or not.
private bool lowSensivity = false;
//remember to change it to "input.GetButtonDown" or the sensivity will keep
//changing for every frame as long as you are pressing the Zoom button.
if(Input.GetButtonDown("Zoom")){
if(!lowSensivity){
sensivityX = 1;
sensivityY = 1;
lowSensivity = true;
}else{
sensivityX = 10;
sensivityY = 10;
lowSensivity = false;
}
}
I don't want it to be held. I want to just have to press, and then it gets less sensitive, and press again to make it more sensitive.
$$anonymous$$ind of. I tried to translate it to JavaScript, but it doesn't revert back to normal after.
the sensivity on X should change, do you have two mouselook components?
Your answer
![](https://koobas.hobune.stream/wayback/20220612095948im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
sensitivity slider/ drop down help 0 Answers
How to use PlayerPrefs to save to floats (Sensitivity Help) 0 Answers
invert mouse Y-axis hotkey & icon de facto standard 0 Answers
How do I take a public float from a different script and access it 0 Answers
I Want to change ,y sensibility on my MouseLook script 1 Answer