The Godot Q&A is currently undergoing maintenance!

Your ability to ask and answer questions is temporarily disabled. You can browse existing threads in read-only mode.

We are working on bringing this community platform back to its full functionality, stay tuned for updates.

godotengine.org | Twitter

0 votes

So basically say for a game like breakout, I have visibility notifier connected to the ball and I emit 'game_over' signal when it exits screen. Problem is, in my pause menu, there's a 'restart level' button which basically just reloads the current scene after calling get_tree().paused = false which in turn ALSO calls the ball's visibilityNotifier's screen_exited signal causing game_over to be emitted even when the person just restarted.

TLDR : changing scenes is calling visiblityNotifier2D to emit signals. How to stop that case?

in Engine by (12 points)

1 Answer

+2 votes

Disconnect the screen_exited signal before changing the scene.

$VisibilityNotifier2D.disconnect("signal_name", target_node, "method_name")
by (1,476 points)

Yeah I was hoping there was a better way than getting a list of all VisibilityNotifier2D and disconnecting them before every scene change.
The other thing beside this which I tried which worked better I suppose was to use a boolean inside of VisibilityNotifier2D for further handling which would allow it to get called as much as it'd like and not hinder the other processes.

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.