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. Dismiss Notice

Pre-loading scenes?

Discussion in 'Scripting' started by DizzyTornado, Jan 12, 2015.

  1. DizzyTornado

    DizzyTornado

    Joined:
    Nov 17, 2013
    Posts:
    134
    Okay everyone I have two questions, so please bear with me.

    [Background] Hello everybody, I'm working on an open world sci-fi game in which you can travel through space visit space-stations and travel to other solar systems and planets.

    Question 1:
    In the game there are 5 galaxies, which are all different scenes, and I want the player to be able to travel between them without resetting their inventory and health, should I use dontdestroy.onload() for this?

    Question 2:
    In the game you can visit space stations, to do this you land in the landing bay and then go into an elevator that brings you to the inside of the station, but I want the space station's interior to be a different scene than the outside but I want the inside to load instantly. Should I make the space station interior scene load as the player is playing the game and flying in space, or should I make it so that when you enter the elevator door it loads a scene that is empty except for you and the elevator, and while you are in the elevator the space station interior scene loads and once it is done loading you spawn in it.

    Sorry for the run on sentences I'm a crappy writer so grammar Nazis don't kill me.
     
  2. Crayz

    Crayz

    Joined:
    Mar 17, 2014
    Posts:
    192
    DontDestroyOnLoad() is probably your best bet. Perhaps when the player first starts the game is the first and only time you should have to load the player data and inventory (or maybe in cases such as when the player dies/respawns)

    You also have access to Additive and Async scene loading (or AdditiveAsync).
    Additive basically means that you can load a scene into your current scene without anything being automatically destroyed, and Async means a new scene can be loaded asynchronously in the loading thread as to not freeze up the game while things are being loaded. Though Async might be a pro only feature, I'm not sure. It's not necessary I guess, just kind of a convenience if your levels take some time to load.

    There's a variety of ways to accomplish these tasks but I haven't worked much with scenes yet, so maybe somebody else could point out some effective methods.
     
    DizzyTornado likes this.
  3. DizzyTornado

    DizzyTornado

    Joined:
    Nov 17, 2013
    Posts:
    134
    Ok, thanks I have Unity Pro so if it's a Pro feature that's ok. Thanks!
     
  4. cmcpasserby

    cmcpasserby

    Joined:
    Jul 18, 2014
    Posts:
    315
    Ya the async load in the elevators is actually what both mass effect and mirrors edge did. It works well but can make for some pretty dam long elevator rides on crappy computers.
     
    Last edited: Jan 12, 2015
  5. hopeful

    hopeful

    Joined:
    Nov 20, 2013
    Posts:
    5,623
    I think my natural approach would be to have a basic scene for the game (even if it is just a galaxy-switching GUI and has no actual scenery) and then additively load whichever galaxy the player needs at the time. If you chop each galaxy up into small chunks and load what you need when it is needed, I think you'll be fine.

    If you already have SECTR or Advanced Additive Scenes you should find it pretty easy to break up your galaxy scenes into subscenes, but you can also do it without them.
     
  6. DizzyTornado

    DizzyTornado

    Joined:
    Nov 17, 2013
    Posts:
    134