Search Unity

Freeze Frame

Discussion in 'Cinemachine' started by darthbator, Jul 9, 2018.

  1. darthbator

    darthbator

    Joined:
    Jan 21, 2012
    Posts:
    169
    So I'm trying to implement a "frame stick" or "Freeze frame" type functionality in my game. I've previously done this in the following manner,

    Code (CSharp):
    1. //FIXME this unsets the active virtual camera
    2.  
    3. public IEnumerator FreezeFrame (int frames) {
    4.         //yield return null;
    5.         while (frames > 0) {
    6.             Camera.main.clearFlags = CameraClearFlags.Nothing;
    7.             yield return null;
    8.             Camera.main.cullingMask = 0;
    9.             frames--;
    10.         }
    11.  
    12.         Camera.main.clearFlags = CameraClearFlags.SolidColor;
    13.         Camera.main.cullingMask = ~0;
    14.     }
    15.  
    However cinamachine appears to not want me to access the camera in this way... this unsets my active virtual camera and leaves me in a broken state. I've tried to address the camera through the cinemachine brain but I get the same result. How am I meant to achieve a feature like this with cinemachine?
     
  2. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,730
    I think the problem is in the culling mask. Cinemachine will only see the vcams that are on layers contained in the camera's culling mask. So when you set it to 0, CM can no longer see the vcams and loses its state. Try putting the vcams on their own layer, and instead of setting the camera's culling mask to 0, set it to that layer. Then CM will still see the vcams.