0 votes

I'm looking into how to handle saving in my game. Down the line, I want to save many variables and I need to do it quite often automatically (there will only be autosave, the player will not press a save button)

Because of that, I don't want to have to save everything in the game every time, only the necessary variables. What would be a good way to save specific variables to the save file and overwrite it if it is already stored?

in Engine by (49 points)

1 Answer

0 votes

Have a global script with a dictionary or array so it can be accessed anywhere

Update the values as normal.

Save dictionary to file on conditions like

  • The game quit
  • A stage got cleared
  • The player has the game idle
  • Save point reached

The saved file automatically overwrites the old one when saved so it may be a good idea to have multiple dictionaries or save files for things like configuration, progress, consumables, status

This is only one approach and not coding law

by (4,478 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.