#What's the best way to save player's progress in level?

1 messages · Page 1 of 1 (latest)

wild lava
#

My game is divided to levels. It should save player's progress in a level only when player reaches a checkpoint. How can i make the game to save things so when player gets back to checkpoint it will bring a scene to the same state it was when player reached it?

next lynx
#

By caching the data at the point in the runtime? Many ways to do it depending if you want to refresh the state of the current scene, but if it's just character specific you're storing any player information at the time of the checkpoint and then reassigning it for when you wish to return to that checkpoint

#

Similarly, if you want to save the state of the scene at that point, then you're going to need to cache more information like all the enemies that you may have killed, coins collected, ect

wild lava
# next lynx Similarly, if you want to save the state of the scene at that point, then you're...

yes, i want to save each enemy, objects that can move/rotate (for example a simple box that can be pushed by player), colleected stuff and objects that were stopped in time by the player's power to stop objects in some range in time
the problem is that i don't know how to save all of these because all ways i found to save data can only save basic variables like int, float, string etc

next lynx
#

If you have a small enough of a game you've got options of just keeping everything in memory such that just disabling objects is ideal and keeping direct references to objects that you may want to re-enable when you go back to the checkpoint.

#

So what I'm trying to say is you save the starting state of all objects that can be changed at checkpoint load*

#

So instead of reloading the whole scene, all you need to do is look at this initial state of objects and reapply that data.

#

Reloading the scene entirely requires quite a bit more tinkering such as just doing a general save/load system with JSON

mint atlas
#

Combination of saving/loading state and scene reloading is probably more reasonable in this case.

wild lava
next lynx
#

In that case, you probably just want to learn to serialize data to JSON

#

It's just that if it's at the runtime you have the possibility to do it by references, but otherwise you'll be doing it by ID serialization

wild lava
#

can you please tell me how can i find whatever i need to make proper save system?

next lynx
#

I'm not too aware of any tutorials that Unity may provide for them. I wonder if Unity Learn has anything involving them, but otherwise I usually surf around blogs and youtube for this type of information. Maybe someone has some better suggestions

mint atlas
wild lava
#

so your idea is to convert objects to json, right? but is it good to make save files easily be changed outside of the game?

mint atlas
#

I would focus on actually creating a save file over what users do with their data. You can add layers or change the serialization logic afterwards if it bothers you.

next lynx
#

Then you got games like Risk Of Rain 2 (made in Unity) that couldn't care for any type of encrypted data

#

just open a notepad and change away

wild lava
#

@mint atlas @next lynx well thanks for help

next lynx
#

I suggest finding a tutorial and getting an idea and if you run into trouble with your code to ask again. It's just a pretty large module to learn so it's not something I can run you through so easily.