- Home /
My Zoom code worked in unity 4.6 and now doesnt in unity 5 anybody any ideas?
var zoom : int = 20; //determines 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 transition 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.GetMouseButtonDown(1)){ //This function toggles zoom capabilities with the Z key. If it's zoomed in, it will zoom out
zoomedIn = !zoomedIn;
}
if(zoomedIn == true){ //If "zoomedIn" is true, then it will not zoom in, but if it's false (not zoomed in) then it will zoom in.
camera.fieldOfView = Mathf.Lerp(camera.fieldOfView,zoom,Time.deltaTime*smooth);
}
else{
camera.fieldOfView = Mathf.Lerp(camera.fieldOfView,normal,Time.deltaTime*smooth);
}
}
What about saying hello-please-thanks-have a good day ? What about some explanations about your code ? What about using the code sample button ?
I believe camera is deprecated. Use this.GetComponent(Camera) ins$$anonymous$$d.
Your answer
