- Home /
Create Level save files from runtime Level Edits
Level Editing & Save in Play Mode?
During gameplay, (PlayMode in the Editor), the player (daughter) can move and add a few types of objects (prefabs) around in the level, in a sort of very primitive level editing, until she's happy with it.
How do I save these changes and additions she's made, during gameplay, in such a way that I can then load a daughter level within the editor and therein turn it into an actual level?
Can this same mechanism be used to help real world players edit, save and share levels?
Answer by SneakyLeprechaun · Jun 10, 2019 at 05:30 PM
Here is a great tutorial on saving and loading data from a file. It's more focused on player stats, however it could easily be converted into a level saver, by simply changing the PlayerData to store a list of the object types and positions. This could be done by having all the game objects that you want to save have a tag 'saveable', and then when you run the save function, get the positions and rotations etc of the objects and save them to an array (in terms of what the object actually is, I don't think you can just store a non-primitive, which means you will probably have to come up with a way around that; maybe by making up a list of all the objects and using a numerical id along with it.
Overall it is a complex thing to do, but it is totally possible, and would be even better if you can make it in game.
Link to the helpful tutorial: https://www.youtube.com/watch?v=XOjd_qU2Ido
THAN$$anonymous$$ YOU!!! I was in need of a starting point, for a mental model, so to speak, of how to do it.
This might be just the treat. Gotta save just position and rotation of the few game object types that can be moved around and added.
Based on this, and correct me if I'm wrong, I think I can make an array of transforms (I don't need the scale, but just so it's easy) for each type, and pair an ID to each based on Left/Right and UpDown position in the level, used as the index... perhaps. This is where I'm a little confused. This should be sorted on save, I suppose, based on left to right, with up/down as the deter$$anonymous$$ant of ID for any two objects at the same x position.
Your answer