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

+1 vote

Disconnect the screen_exited signal before changing the scene.

$VisibilityNotifier2D.disconnect("signal_name", target_node, "method_name")
by (1,463 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 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.