Search Unity

Question Avoiding performance issues when moving camera

Discussion in 'Editor & General Support' started by Danimita92, Feb 28, 2024.

  1. Danimita92

    Danimita92

    Joined:
    Jan 25, 2010
    Posts:
    32
    Hi everyone!
    I have a curious optimization issue I'm trying to solve for my game. For the first 30 mins or so, the game's first-person camera is fixed in a specific position and rotation, looking at a PC screen (you can find screenshots here), but eventually there's a cutscene where the camera turns around, revealing the room you're currently in.

    The issue I'm having is that in a fresh build, when this cutscene happens and the camera begins turning, performance drops significantly for a few seconds. I assume it's because the game is rendering the elements of the room for the first time. Further sections of the game where the camera angle changes are fine, and if I restart the game and trigger this first cutscene again there's no issue, since I imagine it already has the info it needs stored in memory.

    What can I do to prevent this initial framerate hiccup?
    I've considered having a camera looking at the back of the room while loading the game or something along those lines, but it feels a bit hacky :p

    Thanks in advance!
     
  2. CodeSmile

    CodeSmile

    Joined:
    Apr 10, 2014
    Posts:
    5,838
    Platform? Render pipeline? Editor version?

    Does it occur if you build with IL2CPP (if available)?
    Sounds a bit like it could be due to JIT ie runtime script compilation. Or shader compilation (optimization), not sure if that can occur at runtime.

    Also try a release/master build, see Player Settings.