Scene switching and returning?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By genfy
:warning: Old Version Published before Godot 3 was released.

So, trying to create a shop/menu system and I want to change scene but then return to the previous scene exactly as I left it.

How do I do this?

I guess I could just pause the rest of the scene and overlay the other scene over it, but then things could get messy quickly.

:bust_in_silhouette: Reply From: Zylann

Here are a few solutions:

  1. Do as you suggested: overlay the shop on top of the base scene and make sure it’s paused and not processing input. If the shop is just a fullscreen window, you can do this.

  2. If you really want to unload the base scene, use a singleton node to save the state of your base scene, then switch to shop, do your things, then switch back to the base scene.

  3. Same as 2), but without singleton: have a “host” scene with common nodes that instances the map, and when changing to the shop, replace the map by the shop map. This can be handy if you want to preserve the avatar node or other common stuff without reloading the whole scene tree, and I do that currently in my game.

  4. Make the shop seamlessly integrated in the base scene, but this depends a lot of your game, maybe you don’t want this.

Also, this topic has been seen a few times already on Q/A:

Hello. I know I’m late but I was looking for a solution to this problem. I want to follow solution #2 but I don’t know how to. Can you please give me some examples? Thanks a lot

mynamesdat | 2020-03-22 08:06