On fov change, screen position out of view of frustum error

So im getting this error:

My script is this (it zooms and unzooms and if I spam it a lot and bring up the pause panel the camera totally glitches out and gives me that error). I tried the scene closing and reopening and restating unity, this is a new bug since I implimented the zoom feature. Any help would be greatly appreciated. :slight_smile: Script (java):

private var baseFOV : float; private var speed : float = 37.5f;

 
    function Start () {
         baseFOV = Camera.main.fieldOfView;
     }
      
     function Update () {
         if (Input.GetMouseButton(1))
         {
             Camera.main.fieldOfView = Mathf.Lerp(Camera.main.fieldOfView,40,Time.deltaTime*speed);    Time.timeScale = 0.4f;
             Time.fixedDeltaTime = 0.02f * Time.timeScale;
         }
     
         else {
             Camera.main.fieldOfView = Mathf.Lerp(Camera.main.fieldOfView,baseFOV,Time.deltaTime*speed);   Time.timeScale = 1;
             Time.fixedDeltaTime = 0.02f * Time.timeScale;
       
         }
     }

I don’t know how this error can be fixed but when i tried to run your script in my unity editor(in mono develop) to see the errors, it worked without any error and now I am using your code in my game.
Because your code is much more efficient than what i wrote. Your code made difference of 16 lines in my script.

Thanks for your help :slight_smile: :wink: