Question by
B_I_G_Gaming · Aug 31, 2015 at 12:22 PM ·
zoom-in
Zoom in and out?
Hey guys, recently I have been working on a first person shooter script and I have come to a stop with the zooming in and out script:
public class ZoomScript: MonoBehaviour {
public Camera theCamera;
public bool zoomedIn;
public float zoomOut;
public float zoomIn;
public float duration = 5.0F;
private float startTime;
public bool zoomInNow;
void Start() {
zoomInNow = false;
startTime = Time.time;
zoomOut = 60;
}
void Update () {
float t = (Time.time - startTime) / duration;
if (Input.GetMouseButton (0)) {
zoomInNow = true;
theCamera.fieldOfView = Mathf.SmoothStep (theCamera.fieldOfView, zoomIn, t);
} else {
zoomInNow = false;
}
if (zoomInNow = false && theCamera.fieldOfView > zoomOut) {
theCamera.fieldOfView = Mathf.SmoothStep (zoomIn, zoomOut, t);
}
}
It zooms in fine when i press the mouse button, but when I release the mouse button it stays zoomed in.. Any Suggestions?
Thanks, Brandon
Comment