Whenever i use it the camera shakes violently when i hold it in and will only zoom in when I let it go. Also how would i unfocus my camera when its zoomed in so that my fps character is blurry. That’s not something I need but would hepful. Thanks!
Your problem is because your asking if the key is constantly down. Which your then flipping to on off.
this should fix it:
var zoom : int = 40; //<span class="fdx72e" id="fdx72e_12">determines</span> amount of zoom capable. Larger number means further zoomed in
var normal : int = 60; //determines the default view of the camera when not zoomed in
var smooth : float = 5; //smooth determines speed of <span class="fdx72e" id="fdx72e_10">transition</span> between zoomed in and default state
private var zoomedIn = false; //boolean that determines whether we are in zoomed in state or not
function Update () {
if(Input.GetButtonDown("Fire2")){
zoomedIn = !zoomedIn;
}
if(zoomedIn == true) {
camera.fieldOfView = Mathf.Lerp(camera.fieldOfView, zoom,Time.deltaTime*smooth);
} else{
camera.fieldOfView = Mathf.Lerp(camera.fieldOfView, normal,Time.deltaTime*smooth);
}
}