+1 vote

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.

in Engine by (48 points)

1 Answer

+2 votes
Best answer

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:

https://godotengine.org/qa/1883/transfering-a-variable-over-to-another-scene?show=1883#q1883

https://godotengine.org/qa/7891/level-changing?show=7891#q7891

by (29,090 points)
selected by

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

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.