|
|
|
|
Attention |
Topic was automatically imported from the old Question2Answer platform. |
|
Asked By |
da_dev |
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?
|
|
|
|
Reply From: |
GameVisitor |
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
I switch scenes by get_tree().change_scene(), but I think PopupDialog would suit me better
da_dev | 2019-06-09 11:00
|
|
|
|
Reply From: |
sparkart |
If you decide to maintain scene state via file storage, you can use PackedScene.pack(node)
Here’s some documentation that demonstrates this