The Godot Q&A is currently undergoing maintenance!

Your ability to ask and answer questions is temporarily disabled. You can browse existing threads in read-only mode.

We are working on bringing this community platform back to its full functionality, stay tuned for updates.

godotengine.org | Twitter

0 votes

So I create an instance of a kinematic body in the main scene. Then if I switch the scene to menu.tscn and back, stats of a body reset. I thought maybe I could use a script where I could save all of the stats my body have, but what I have multiple bodies and how do I get position and rotation of every single one?
Maybe I should not switch scenes at all? But how do I then create menu?

in Engine by (32 points)

2 Answers

0 votes
Best answer

How are you "switching" the scene ?

If you are loading it, whenever a scene is loaded, all previous scenes do not exist and the new one is loaded with its default values / settings. If you are doing this, you need to manually save the data / variable states either in memory thru global scripts or to a file.

You can also check the responses here and here for a similar question.

Also, you could (depending on your case) not change the scene but use a PopupDialog menu, usually used for pause menus.

Hope this helps :-)

by (892 points)
selected by

I switch scenes by gettree().changescene(), but I think PopupDialog would suit me better

0 votes

If you decide to maintain scene state via file storage, you can use PackedScene.pack(node)

Here’s some documentation that demonstrates this
https://docs.godotengine.org/en/3.1/classes/class_packedscene.html#class-packedscene

by (343 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.