Hi i need a little help, i have a zoom script. So here is the problem, i have 2 cameras, and when i switch to the camera who has the zoom script enabled it’s zoomed in automatically, i want the zoom to be 0 when he switches. And i want too zoom only when the character is standing and moving normally(like the Outlast game), so when he sprit’s(LeftShift) he’s not able to zoom.
Here is the script:
public class ZoomIn : MonoBehaviour {
public float zoomSensitivity= 15.0f;
public float zoomSpeed= 5.0f;
public float zoomMin= 5.0f;
public float zoomMax= 80.0f;
private float zoom;
void Start() {
zoom = GetComponent<Camera>().fieldOfView;
}
void Update() {
zoom -= Input.GetAxis("Mouse ScrollWheel") * zoomSensitivity;
zoom = Mathf.Clamp(zoom, zoomMin, zoomMax);
}
void LateUpdate() {
GetComponent<Camera>().fieldOfView = Mathf.Lerp (GetComponent<Camera>().fieldOfView, zoom, Time.deltaTime * zoomSpeed);
}
}
Can anyone help me please?