0 votes

Hello,

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 Userdata.gd (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.

Godot version v3.3.2.stable.official
in Engine by (31 points)

1 Answer

+1 vote

Hi.
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.

by (3,932 points)

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?

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 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 webmaster@godotengine.org with your username.