edited February 2014 in General Discussion
So I'm having a few issues with my current implementation of levels.
I'm using a random dungeon generator to generate a dungeon when a player starts the scene. The issue is that obviously when a move scenes the dungeon is lost, along with any changes that may have been made to it.
I'm trying out Unity Serializer at the moment to see if I can get it to save the dungeon and reload it when the scene is loaded. This seems to be quite slow at the moment and Unity Serializer seems to be having some odd issues with the more recent versions of Unity. I've almost got it working but I can't help but think this is a problem someone must have experience and dealt with before.
Any suggestions on possible solutions?

Cheers :)
  • Usually, any random generator should be able to reproduce the same content when using the exact same settings/values.
    So, theoretically it should be possible to recreate your random level when you save the settings/values used to create it the first time - and you could store/load them with ORK (e.g. in game variables).
    Please consider rating/reviewing my products on the Asset Store (hopefully positively), as that helps tremendously with getting found.
    If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
  • edited February 2014
    True, I can regenerate the dungeon using the same seed. The only problem I can think of is that doors or chests, etc that had been opened or changed would be regenerated as well.
    I'm currently thinking of loading the dungeon into it's own game object and marking that as DontDestroyOnLoad and just disabling it when I want to jump to a battle scene then re-enabling after the battle.
    I suppose I could save the changed objects separately via variables as well.
    Post edited by LordHogFred on
  • If your doors and chests are tied into ORK's system (e.g. being events, item collectors/boxes), i.e. using Scene IDs or Game Variables, they'll automatically be saved with the rest of the game (their state).
    Please consider rating/reviewing my products on the Asset Store (hopefully positively), as that helps tremendously with getting found.
    If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
  • So I'm just coming back to this and I'd like to use the approach you suggested.
    I'm having some problems getting my head around how to track the variables properly. I've got a single scene that is used to generate the dungeon, when the player goes down a level the dungeon is regenerated in the same scene. I can't use multiple scenes as I don't know how many floors the player may end up going down.

    I got a script set up that assigns an ObjectVariableID based on the current dungeon seed and the objects location so these should be unique for every floor. The problem I'm having is how to use the same formula I used to assign my object ids (prefix_seed_xyz) when referring to other variable keys.

    I may be going about this in the wrong way and there may be a far easier way to do this, if so I'd love to know :p. Another approach I was thinking of was to have a dictionary (one for doors, one for chests, etc) that has the dungeon seed as the key and then stores the related variable as it adds doors sequentially (the dungeon should generate doors in the same order every time so this should be ok).

    I managed to get UnitySerializer to dump my entire dungeon to a file which I can then load back in. However, if I can stick to just using the ORK variables that would be preferable.

    Thanks in advance :)
  • You can get/set the game variables in code as explained in this how-to (at the bottom).

    When you're randomly generating the variable keys, you could skip using object variables and use normal (global) game variables instead.

    Generally, you can also store the variable keys in game variables and use them to access game variables (using Game Variable as value type in the variable key and typing in the name of the game variable that holds the name of the key).
    You could use this to set up a bunch of (string) game variables to hold the actual keys for your randomly generated level.

    E.g.: When initializing your random level, set up multiple door variables (e.g. 'door1', 'door2', 'door3', etc.) and store the randomly generated variables for the doors (prefix_seed_xyz) in them.
    This way, you can always access the variables in the scene by simply using 'doorX' as variable key (with Game Variable value type).
    Please consider rating/reviewing my products on the Asset Store (hopefully positively), as that helps tremendously with getting found.
    If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
Sign In or Register to comment.