Guide to the Godot game engine/Saving and loading

Most game engines allow you to save files. Godot is no different.

There are five methods to save files, and each method has at least 1 loading method.

Resources
These can be loaded with GDScript's built-in  function. See creating resources for more.


 * Pros
 * Load and save built-into Godot
 * Cons
 * Hard to debug

Json
Commonly used for sending data over the internet. It's easy to read and modify, so consider compressing or encrypting your save file to prevent cheats. This is especially important in multiplayer games. Alternatively, save player data in the cloud. This will require setting up a server.


 * Pros
 * Easy to debug
 * Fast saving/loading times
 * Cons
 * JSON does not define s, only numbers. All numbers comes out as a.

File
Files can be opened and parsed with the object.


 * Pros
 * Easy to debug
 * Easy to encrypt to prevent cheaters
 * Cons
 * Can be hard to parse

Xml
Xml is a simple file format, but hard to parse. See.


 * Pros
 * Widely supported
 * Cons
 * Hard to parse

Scenes
This can be done by calling, which turns it and any child with   set to it, which can be saved with   and loaded with.


 * Pros
 * Built into Godot, can be rather fast
 * Cons
 * Saves everything, difficult and time-consuming to select what to save
 * Hard to debug

You can exclude a node by setting its  to. To include a property, make the property exported. If a node's  property to anything other than the node that   is called on, it will not be saved. Note that this property will have to be set to anything that is added to the scene by script, as they start with no owner.

Tips

 * Really large files can take almost a whole minute to load. Consider splitting save files up into more than one, and only load each file when needed.