Losing Data when changing scene

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

In my main-scene I create some viewports with games in them.
I also save the games in a dictionary in the global-file.
When the games are over I want to show a Leaderboard-scene, but when I change the scene my viewports inclusive the games are empty.

How can I solve this?
Ty for helping in advance:)

cant really help if theres no code

lewis glasgow | 2021-08-01 13:53

:bust_in_silhouette: Reply From: ccpixel

You could try using an Autoload to store the necessary variables across scene changes.

I don’t know how you are changing scenes, but instead of replacing the entire scene you could have a root node that has a function to swap out child nodes to change the scene the user can view. In this way you wouldn’t “lose” all the scenes that were loaded because you would only be changing some of them.

For example, your scene tree may look like

- Root
  - SomeNode
  - World
      - children

And you would swap out the children of World but keep other nodes loaded.