Create a high-level saving/loading API based on the high-level multiplayer API #7005
Replies: 4 comments 20 replies
-
Besides saving and loading to file, this can also be used to produce game snapshots for e.g. Prince of Persia Sands of Time style time-rewind. It can also be helpful for implementing rollback netcode, although that would require a few extra pieces. The biggest challenge, IMO, in implementing this is order of operations: You can't set properties on a node before it was spawned. So the correct order of spawning and synchronizing needs to be maintained, while making sure not to leak any memory when anything is despawned. |
Beta Was this translation helpful? Give feedback.
-
To be truly useful I feel this also needs to allow you to extract the serialized data as a dictionary or array, and provide custom data directly (virtual save/load methods for example) to avoid restricting users to a specific save format and save method, for example allowing you to save in some custom way, send it over network, compress it, etc. There's always a risk of a feature only being useful for certain situations, or certain levels of complexity, a built-in save system can easily become restrictive to users with complex setups, though providing ease of saving to relatively simple projects, or relatively new users, has its own merit The tools already available for users with groups and similar are powerful, but can be hard to implement as a beginner |
Beta Was this translation helpful? Give feedback.
-
Saving a Game is as simple as keeping all the variables you want to keep in using the It's quick and easy to implement, performs much like editor saving performs and loading is simply a matter of changing to the scene you saved, and as a bonus you can open Saves in the Editor if you wish to Debug something or just tweak the values to Mod the Save |
Beta Was this translation helpful? Give feedback.
-
For what it's worth, the I can definitely see the value of the |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Godot does not do much in the way of helping users save and load their games. On the other hand, it has a great high-level multiplayer API by way of
SceneMultiplayer
,MultiplayerSpawner
, andMultiplayerSynchronizer
, which make it possible to set up multiplayer through the editor. Multiplayer and saving/loading are similar tasks in that they both involve serializing/deserializing game data. I propose creating a similar high-level save/load API similar to the multiplayer API to make it easier for users to save and load their games.The high-level save/load system would consist of three main components:
SceneSaver
(analogous toSceneMultiplayer
)SaveGameSpawner
node (analogous toMultiplayerSpawner
)SaveGameSynchronizer
node (analogous toMultiplayerSynchronizer
)Here's how it would work. In any scene with nodes whose properties need to be saved/loaded, the user places a
SaveGameSynchronizer
. They configure the node to point to those properties. In any scene that will instantiate other packed scenes at runtime, the user places aSaveGameSpawner
and configures it to point to those packed scenes. Finally,SceneSaver
will expose global methods likesave_game
andload_game
that can be called from anywhere.Here's how the scene tree for a simple game involving a Player scene and some enemies that spawn on a timer (like the Dodge The Creeps tutorial game https://docs.godotengine.org/en/stable/getting_started/first_2d_game/index.html).
Main
Player
Enemy
What do you think?
Credit: @SlugFiller for coming up with the idea and looking over this proposal, as well as @YuriSizov for participating in the discussion that spawned this idea.
Beta Was this translation helpful? Give feedback.
All reactions