Skip to main content

  | मौसम…

411 समाचार
Public archive edition · Attributed source reporting with original dates · AI drafts are excluded

411 REFERENCE · Wikibooks

Guide to the Godot game engine/Saving and loading

Reference material by Wikibooks contributors. This retains its source identity and is not 411 news reporting.

Physics Animation 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. Methods Resources These can be loaded with GDScript's built-in load() 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 ints, only numbers. All numbers comes out as a float. File Files can be opened and parsed with the File 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 xmlparser XMLParser. Pros Widely supported Cons Hard to parse Scenes This can be done by calling Node.pack(), which turns it and any child with owner set to it, which can be saved with resourcesaver ResourceSaver.save() and loaded with load(). 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 owner to null. To include a property, make the property exported. If a node's oowner property to anything other than the node that pack() 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. Notes Prior to Godot 4.0, file sizes cannot be larger than 24Gib (gigabytes). A useful text file format is "csv" (comma separated values), where each value is comma (",") separated. Use String String.get_csv() to separate them. 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. <noinclude> Physics Animation