Is it a bad idea to save my game in a .tscn file?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By SebSharper

I have a game that is yet to implement a saving system. I want to have different save files (like in Tloz: ALTTP). My game has an inventory system already implemented.
I was looking on the internet and saw there is a particular way of saving the current scene along with its respective children and its variables/properties. This method is implemented using the ResourceSaver , which one that turns the scene into a PackedScene and saves it to some desired path (in my case “user://save_files/“) , then, I would load it from that path and instance it, as explained here.
The multiple save files should be that: multiple .tscn files that save your last scene (saved_scene.tscn, saved_scene2.tscn, …)
I already did some tests with an specific project I made to use this in a small scale. Works pretty well. It also saves export variables which is useful cause my Inventory’s items have the variables I need to save as an export variable already.

However, I haven’t seen people talking about this, neither recommending it nor saying it is a bad idea/practice. That’s why I asked this question. Do you think it is a good idea to implement this?

:bust_in_silhouette: Reply From: Magso

It depends on how the game is setup. You’ll mainly have to keep code very minimal in _ready or have a lot of if statements for references.

Another issue is how the game uses nodes for e.g. if you have a ragdoll version of the player for a death state that resumes after a yield but you save before it times out, loading the game will now cause the player to be a perminant ragdoll so now it has to check this state using match or if else, and there may be tons more cases of this.
At this point it would be easier to either have save points in the map or only save the position and rotation of the player.

Sorry for not specifying. My game is a 2D top down shooter. I think I could remove, for example, the bullets and other objects I don’t want when the scene is created, right?

SebSharper | 2020-09-07 16:08

It depends on how complex your game is.
Also it might be worth removing the objects you don’t want just before saving to keep file size down and it stops any unwanted initial behaviour upon loading.

Magso | 2020-09-07 16:50

And how could I remove those specific nodes without it affecting the game? I mean, I could remove them from the tree and then add them again but wouldn’t that be a problem when working with bullets or some other thing? Like it would just disappear for a moment and then reappear

SebSharper | 2020-09-07 16:54

Do you mean to save the scene during runtime? If so that would cause a lag spike and you would end up having to save everything including bullets etc.

Magso | 2020-09-07 22:00

I see. What do you think would be the best way of implementing the save system?

SebSharper | 2020-09-07 22:05

I personally would create an array for the positions of the player and enemies and save the array in a cfg file.

Magso | 2020-09-07 22:29