Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice

Discussion Has anyone managed to make a game with seamless scene loading?

Discussion in 'World Building' started by drsalvation, Jan 2, 2024.

  1. drsalvation

    drsalvation

    Joined:
    May 2, 2014
    Posts:
    48
    I eventually want to make an open world game, but for now I'm trying something in a smaller scale.
    Think of Resident Evil 2 remake, or Sekiro.
    A game with a large interconnected map divided by smaller segments.

    For now I'm working with Sectr, and I have main scene that loads in smaller scenes as the player approaches them. However, it seems that even small scenes with few assets still cause a hickup when they load. It's not the loading time that causes the game to freeze, it's that once they load, the game freezes for a second.
    Often times I see general advice like "optimize materials" (they're mostly still the default HDRP lit materials, there are some special materials but they're not in all scenes), optimize meshes (which all are fairly low-poly, I don't know how much more optimized they can be when a wall only has 2 triss), and to avoid lots of game objects with start functions, which is a good assessment, if only I had any game objects with scripts attached, most testing scenes are mostly colliders, mesh renderers, lights.

    I was thinking of maybe making the small scenes start with every game object disable, then create a script that has an array of the scene game objects and iterates over them enabling them one by one in a coroutine with a wait for end frame, it doesn't make loading "faster" but maybe it can spread out the load in the loading process? I was also thinking about maybe having larger scenes, which would mean less loading cycles, and a lot more room to begin loading the next scenes (But I assume more resources loaded into the scene).

    To me it's been demotivating that I can't get a game with small scenes to load without hiccups and I've been considering other possible engines, but I also see that games like firewatch and subnautica play very smoothly, even on my steam deck. I also know for a fact that firewatch also uses Sectr. I'm just one guy with a full time job so I don't have a team and a lot of time to work on my game (which I've been working on for years now, so it's not about me wanting everything fast and easy, but rather, losing hope and patience), but I'm wondering if anyone has managed to do something large-scale like those games in a smooth way?

    I'm not asking for code lol, just any suggestions on what could help?
     
  2. You already answered this. Yes. Including the good folks at Campo Santo.
    Well, you described what a person would describe when play your game. But you aren't a player, you are a developer, it's time to learn how to measure performance, how to find out what is causing your freeze.
    So, you will need to familiarize yourself with the various profilers and find out the root cause of your problem then you probably already will have some ideas how and what to fix and then if you share, probably the good folks of the forum will have some too.

    You can start here.
     
    Ryiah likes this.
  3. spiney199

    spiney199

    Joined:
    Feb 11, 2021
    Posts:
    7,795
    Also make sure you test scene loading in a build and not just the editor. Scene loading in the editor is generally always a bit slow.
     
    Ryiah likes this.
  4. fadeawaygod

    fadeawaygod

    Joined:
    Mar 9, 2015
    Posts:
    25
    Are you load scene in main thread? think about load it in other thread. the unity apply this function in scene loading .and also you need to Reduce the priority of the loading thread.
    Of course you need to pre load your scene Dynamic.
    You can finish it.
    I can’t wait to see an open map Resident Evil.
     
  5. drsalvation

    drsalvation

    Joined:
    May 2, 2014
    Posts:
    48
    Thanks everyone, I think my main concern is how exactly was I supposed to load async loading. I felt like loading a scene async but having it instantiate several game objects on load was not a good approach and I wasn't sure if I had to handle any other type of optimization (like loading individual game objects one at a time).
    I admit I'm not too familiar with profiler, every time I tried debugging and searching on google the cause of the spikes, it seemed to be more of a unity thing and not my scripts or materials, and the results weren't very helpful on how to work around them.

    I updated to the latest LTS version (the one ending in 16), my middle mouse click pivot is still broken, but I did notice that my standalone builds were actually a lot smoother than the editor, I didn't notice the hiccups at all (tho some scenes did take a little longer to load, but that's a problem I'm happy to have).

    I think the main reason why I was having issues could've either been part of a previous version of unity, or the fact that I would test run the exported game right after exporting it (that is, with unity still open).

    In short, I was just wondering if anyone here had to do some other optimizations when loading scenes other than just loading them asynchronously.
    That said, I definitely need to become an expert with profiler, so thanks for the link!
     
  6. marcoantap

    marcoantap

    Joined:
    Sep 23, 2012
    Posts:
    221
    No. Unity is great loading the first scene and that's it. You are supposed to use addressables to load the next scenes smoothly. I use a single huge main scene, because every other scene uses the same assets and there's really no benefit in unloading the few that might not be used. Just enable and disable the subscene gameobjects. That's the fastest least painful way tested in resource constrained systems with Windows and Linux.
     
  7. That is maybe true for your game but may not true to other games. It is certainly not true to the games I help out. There are some (well, many) things shared between locations, but certainly beneficial to unload the unused ones when probably won't be used for a while in order to lower the memory consumption so we can fit other things in memory.