0 votes

Is it possible to use the following method to save the game (I know it will be very slow): save the current scene to a .tscn file, and then change the main scene to this scene?

Godot version 3.5.1
in Engine by (90 points)

What following method?

My method:save the current scene to a .tscn file, and then change the main scene to this scene. I can do this in Godot 3.5.1?

Yes, that should be possible.

Do you know how to do it?

2 Answers

0 votes
Best answer

Відповідь на це питтання є. Треба написати функцію яка буде збирати всі потрібні дані з об'єктів, зберегти в файл SAVE/DAT, а потім завантажити це. Це є в стандартному підручнику Godot про зберігання ігор.

by (90 points)
0 votes

If I've understood correctly, you might be looking for the ResourceSaver

It will save any Resource as a tscn file, which should include Scenes I think.
Switching scenes is done with the SceneTree class. it might be what you're looking for.
But it might be better to save the state of each thing in a scene instead and then you can load the savegame back later re-spawning everything using the saved data.

Here's an example of how to save and load gamestate

by (52 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 Frequently asked questions and 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 [email protected] with your username.