0 votes

Hello everyone, I was writing game codes when I encountered a problem. When I put the button to return to another scene in the pause menu, for example, to return to the main scene, the buttons that worked before do not work anymore and the stage does not enter. So I wanted to know if there is a reason that these buttons only work once? Is the problem of returning to the scene again?

in Engine by (26 points)

2 Answers

0 votes
Best answer

The problem is solved, but if you have this problem, be sure to use this line of code. It worked for me

get.tree(). change

by (26 points)
0 votes

I would suggest putting scene change logic inside of Singletons. They’ll stay persistent through your code and allow you more easily control which scenes are being displayed at any given time.

If you are already using these I could provide better advice too!

by (135 points)

Thank you for answering my question. Actually, I was not very active in Godot. For example, the scene change code is this...

func onlevelskeypressed() -> void:

What is the problem with this?At first, all components work, but they are disabled when returning to the same scene!

What I would do is take that Singleton logic called SceneHandler.tscn or something of that order.

Then have a function called changescene(scenepath)

From there when you do your on levels key pressed():

What may be happening is when you call a change scene from within the same scene, it can kill your current one and you are left with a gap of logic. Basically you want an always running Singleton in the background that controls it all and will never stop running through your games lifecycle.

I hope this was helpful and the article I sent was helpful in the previous post. Please do tell me if it wasn’t or if it needs more details and I’m happy to update it. I’m trying to build some good resources for people working with Godot!

Hopefully more tutorials to come ;) and I hope this helped you

This method did not work. But thank you

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.