Hi.
I have a problem in my scene: When switching between cameras by enabling one and disabling another there is a small, but noticeable lag in the game (about half a second).
There are three cameras (Default, Zoom, Underwater). What’s the best way of switching between them in an FPS game?
Here is my Code:
public enum CameraType {Default, Zoom, Underwater};
private CameraType activeCamera = CameraType.Default;
(...)
private void ToggleCamera(CameraType newCamera)
{
switch(newCamera)
{
case CameraType.Default:
activeCamera = newCamera;
defaultCamera.enabled = true;
zoomCamera.enabled = false;
underwaterCamera.enabled = false;
break;
case CameraType.Zoom:
activeCamera = newCamera;
zoomCamera.enabled = true;
defaultCamera.enabled = false;
underwaterCamera.enabled = false;
break;
case CameraType.Underwater:
activeCamera = newCamera;
underwaterCamera.enabled = true;
defaultCamera.enabled = false;
zoomCamera.enabled = false;
break;
}
}
There are no Errors or Warnings from the Code, everything works except for that annoying freeze/lag when ToggleCamera(…) is called.
I know that i could put all ImageEffect-Components on one Camera and activate/deactivate them as needed but there is bound to be a better/cleaner way…right?
Edit: My Unity Version is 5.2.1f1
Thanks for any advice!
Yours,
Martin