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 :)
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).
If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
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.
If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
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 :)
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).
If you're enjoying my products, updates and support, please consider supporting me on patreon.com!