For menus, is it better to change_scene or to instance scenes by coding?

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


Currently I have a problem with losing the player position whenever I open and then close a menu (for example the inventory).
The reason for this is that to open up a menu, I use get_tree().change_scene() .
To resolve this I have two options:

  • change the player position value in my (primarily used for saving files) upon each use of any menu.
  • or instance the Menu scenes via coding, by using add_child(), and then queue_free() to close the menu and keep the player in the same position.

Any advice would be appreciated.

:bust_in_silhouette: Reply From: klaas

why not simply overlay the screen with your menu? Then you just have to toggle visibility of the menu.
Maybe you have to toggle the mouse->filter property too.

Hm… You’re actually right. I guess I’m overcomplicating things again, as always.
I guess I’ll just instance the inventory node within the player node, without using any specific code for it.

One more thing though… I created a menu upon pausing the game. Right now I manually put it in every scene where pausing is possible. It is basically a small overlaying menu, that also makes the current scene darker while active.
If I am to keep it as an overlay, where do you recommend placing it? In the Player scene just like the inventory?

haha-lolcat1 | 2021-08-13 00:14