Freelook with tweaks

I wanted an RTS-style camera, with free look enabled when holding down the middle mouse and the scroll wheel zooming in and out.

So I made the below changes to the standard FreeLookCam.cs script

public float minFov = 15f;
public float maxFov = 90f;
public float sensitivity = 10f;

protected void Update()
{
    if (Input.GetMouseButton(2))
    {
        HandleRotationMovement();
    }
   
    ...

    var fov  = Camera.main.fieldOfView;
    fov -= Input.GetAxis("Mouse ScrollWheel") * sensitivity;
    fov = Mathf.Clamp(fov, minFov, maxFov);
    Camera.main.fieldOfView = fov;
}
1 Like

Privacy & Terms