Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

camera pause / lag problem

Discussion in 'Editor & General Support' started by JonnyHilly, Sep 2, 2010.

  1. JonnyHilly

    JonnyHilly

    Joined:
    Sep 4, 2009
    Posts:
    749
    I have a second camera (for rendering a gun scope view)
    but when I turn this on and off, there is a huge pause... up to several seconds on some machines...

    is there a way to get rid of the pause..
    I only want that camera to render when in zoom scope view... not all the time.

    Code (csharp):
    1.  
    2. camScopeObj.camera.enabled = true;
    3.  
    or...
    camScopeObj.camera.cullingMask = ~0;


    help appreciated, thx
     
    Sep200 likes this.
  2. JonnyHilly

    JonnyHilly

    Joined:
    Sep 4, 2009
    Posts:
    749
    anyone ?
     
  3. Prodigalpops

    Prodigalpops

    Joined:
    May 5, 2010
    Posts:
    86
    I've not tried this but perhaps you could try using a layer and culling mask option instead of setting the camera on and off.
     
  4. JonnyHilly

    JonnyHilly

    Joined:
    Sep 4, 2009
    Posts:
    749
    good idea, thanks.

    I tried it, but its exactly the same...
    IT seems to be something like unity is doing garbage collection or something similar and deleting all the camera's resources when its not rendering anything.
    (same result wether camera renderer is disabled, or if the culling mask is set to 0)

    If you repeatedly change camaers quickly... multiple times... then its an instant change and there is no lag ever... however if you wait just a few seconds, and then switch cameras, there is a large lag.

    does anyone have any idea how to stop this from happenning ?
    thanks
     
  5. JonnyHilly

    JonnyHilly

    Joined:
    Sep 4, 2009
    Posts:
    749
    some more interesting info....

    This pause does not show up on the profiler.
    It also pauses the profiler.

    its like a case of missing time...

    any ideas ?
     
  6. JonnyHilly

    JonnyHilly

    Joined:
    Sep 4, 2009
    Posts:
    749
    replying to myself again.... first sign of madness.

    anyway...removed the second camera, and tried a 2D overlay for scope view, and jist change the Field of View of the camera to get the zoom effect....

    surprise surprise... the big pause/lag is still there, even when using only one camera. !! :eek:

    anyone know if this is a known issue, or any fixes to it ?

    have run out of ideas of how to make scope view work.
     
  7. JonnyHilly

    JonnyHilly

    Joined:
    Sep 4, 2009
    Posts:
    749
    ok another update....

    Zooming the FOV slowly (instead of instantly) just spreads the lag out into several smaller lags.

    But now at least it shows up in the profiler... as a culling problem.

    I guess Unity doesnt like you changing the view frustrum. ?

    55% of frame time in Culling->Terrain.CullAllTerrains->Terrain.Heightmap.Rendertep3

    and 41% in IslandWater.OnWillRenderObject->Camera.Render->Culling
    even though there is no water (or water shader) in the scene!

    any ideas ? please... help ? agk.
     
  8. Paulius-Liekis

    Paulius-Liekis

    Joined:
    Aug 31, 2009
    Posts:
    672
    This sounds strange - camera shouldn't be so sensitive to such changes. Could you make small project which reproduces the issue and submit as a bug and post the case number?
     
  9. Sep200

    Sep200

    Joined:
    Jul 29, 2013
    Posts:
    13
    I have the same problem, when switching to my scope cam in my shooter, there is a huge lag and I have no idea how to fix it!