This site is currently in read-only mode during migration to a new platform.
You cannot post questions, answers or comments, as they would be lost during the migration otherwise.
0 votes

I want to save the current scene to a .dat file, then load and open it when needed. Currently, I'm saving get_tree().current_scene to the file, but I can't find a way to get the scene from that.

Edit: I've found a workaround, which is just to save the root node's path. I know that it won't work if the scene and root node have different names, but it works for now. I'd still like to know if there's a better way to do it, which is likely.

in Engine by (112 points)
edited by

1 Answer

0 votes

Try instancing it as a child of another node. Like this.

--Scene you want to load

-root will manage the instancing but nothing else.

And if you don't know how to instance, hears an example.

var scene = preload("res://exampleScene.tscn").instance()

by (663 points)

sorry, if your loading from user. then try user:// instead of res:// I think that's right. And if you use .dat then replaceing the .tscn with .dat should work.

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.