How to persist object state in scene when changing the scene level ?

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

HI
I have no idea about how to persist the object state in scene (not saving) when the scene is changed.

for example, the situation which I want to implement.

  1. at level1 initial state, >> there is only a player in level1.
  2. then, player plants a tree >> instance a tree in level1.
  3. player move to level2
  4. player comes back to level1 >> the tree is still in level1
  5. if player quite the game (without saving) and re-open it again >> go to level1 initial state, which doesn't have any tree

Thank you for your help.

Read the point 3 in chapter Change scenes manually and see if that works for you.

lacethespace | 2020-03-03 12:16

:bust_in_silhouette: Reply From: njamster

You could store the changes to a temporary savefile that you delete once the player exits the game - or copy into the regular savefile, when the player saves manually.

Click here for an introduction on how to save games in Godot.

While setting this stuff up can be a lot of work, I’d argue it’s worth the effort, especially when your game gets bigger and memory use becomes a more important factor. It’s also worth pointing out that this gives you a lot of control about what to load and when.

thank you for your answer sir.

unlasting | 2020-03-04 16:03