Best place to store save game code?

I want to the save game every death, click and when they get a new record.
Where is the best place for me to store the save and load code?

Game Mode?
The Player Character?
Where?

1 Like

In the save game object. You make a new one of those bad boys, fill it with information you need to save. Theres a learning curve for using the object though so make sure to watch some videos on it.

Storing the actual information though should go into a child game instance - which will carry across all levels until the user closes the game. Combine the game instance with the save object and blamo! You got yourself a save system. Bonus tip: dont be afraid to make functions on the game isntance. Itll act as a really helpful utility tool too.

There are some nodes I cant use in the save game object that I need however?. All my variables are in there tho.

You don’t write code in the save game object, it’s just for storing variables.

It really depends on what goes into the save object.

If it’s pure user data (number of lives, inventory etc), then the player controller is the best place.

If the save object stores data relating to the world (level progress, enemies defeated etc), then the game mode would be the best place.

If it’s a combination of both, user and world data, then the game instance is the best place to access the save object.

Each class should only be accessed by objects which genuinely care about the class. For example, a widget designed to display the remaining lives of the player, shouldn’t really need to access the GameMode (used for rules of the level) to access the save object, to then retrieve data related to the user.

Sometimes, it might be worth having multiple save systems. It entirely depends on what data needs to be stored and the complexity of the application and the mechanics required to access such data.

Hope this helps.

Alex

1 Like