This site is currently in read-only mode during migration to a new platform.
You cannot post questions, answers or comments, as they would be lost during the migration otherwise.
0 votes

Hello. I am trying to connect a finish flag(switch scene to menu when the player body enters) to my menu. I am using a signal to connect. I am unable to connect the normal way due to them being in a different scene. How should I do this?

My code for switching scene and emitting the signal:

func _on_Area2D_body_entered(body: Node) -> void:
Godot version v3.4.4
in Engine by (32 points)

2 Answers

0 votes

Hello :)
This is not a direct answer, but I think it is not possible to emit the signal after the scene has been changed. The change of the scene will (I think) free the old scene from memory before loading the new one.
My workaround would be:
Create an autoload (Singleton). This is a script which will be active all the time and can be accessed from everywhere by its name (look up how to set up an autoload script).
Then when the menu loads (_ready func) let it check with the autoload if the finish flag has been reached. Then let the menu react accordingly.
Hope this helps!

by (16 points)
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.