Saving progress architecture

Hi! I want to implement a save system in my game early and need an advice about variables.

My game is metroidvania type game, so I have player, enemies, many scenes, states of pickups, states of bosses, dialogues state etc. How do I save all of this? I mean, do I need to save all my data in just one static script or is there other options? For example, I’ve got a player. It has speed, attack power, abilities and more. And it’s handy to have all them variables in the corresponding scripts. But to save data from 50 different scripts is not the way, am I right? Then how do I handle this? Where should all my variables be stored?

Thanks for help. As a junior developer architecture kind of questions are the hardest for me.

create a class that has all those variables and then serialize and deserialize as needed. you can use binary formatter or json for serialization

1 Like

That I know. But do I need to use this class in all my scripts that use variables from it? Like, do my PlayerController class needs to have it’s own variables that, if changed, change SaveData class variables? Or do I need to inherit from that class? If I have a 1000 variables in one class, it doesn’t seem very convenient to use it as a primary class for all the routine needs of my game. Then how do I approach to this?

when you want to save make the class collect all your variables from across your scripts.

When you want to load make the class assign all the variables to each of your scripts

Heres an amazing tutorial by brackeys: