Signal errors when changing scene

I have a scene where the gameplay takes place.

I want to run
get_tree().change_scene_to_file(“res://mission_summary.tscn”)
which will be a new scene, that acts as in-between the various game modes

However, when this line runs , I get following errors:
E 0:00:13:921 emit_signalp: Can’t emit non-existing signal “changed”.
<C++ Error> Condition “!signal_is_valid && !script.is_null() && !Ref(script)->has_script_signal(p_name)” is true. Returning: ERR_UNAVAILABLE
<C++ Source> core/object/object.cpp:1176 @ emit_signalp()

This error is always repeated 21 times , but the scene switch actually happens successfully.

I do not understand this error message, because no signal is being emitted at the time of the scene switch. And no specific signal is called out in the message. I tried to comment out various parts of code that have signals defined or emitted, but it does not seem to affect the number of 21 times errors in the log.

Please help, it is driving me crazy :confused:

the only thing I can find is this discussion: Errors when changing scene using change_scene_to_file() · Issue #85852 · godotengine/godot · GitHub

but tryin to wrap my scene switch with call deferred did not help
get_tree().change_scene_to_file.bind(“res://mission_summary.tscn”).call_deferred()

Could you provide the code where you change the scene?
Maybe try to put a print_debug() into tree_exited in the changing file, to see if the errors are getting thrown while loading the new scene or unloading the current.
Do you get the same error with SceneTree.change_scene_to_packed()?

In this issue the problem is, that some processes are not finished when changing the scene, so they try to access a part of the old scene, which just has been deleted. This causes a crash. call_deferred() ensures that all other processes are finished before changing and therefore fixes this type of error.
You seem to be having that something tries to emit the signal “changed” which does not exist.
This should be unrelated to the processing order.

Is “changed” a signal you are using or emitting yourself?

I tried below and result was the same for all variants below :

I did not name any of my signals “changed”. So that’s why it is confusing , not sure what signal is actually causing those

Not sure how to do this print_debug into tree exited. Can you please provide more details?

add this function:

func _exit_tree() -> void:
	print_debug("exiting tree")

also maybe try to change to an empty testing scene instead just to see if your scene is related to the problem

this is the only stuff that apparead in the log :

exiting tree
At: res://scripts/master.gd:56:_exit_tree()

right that makes sense you said you where not getting errors in the log, then please put a debug point at the print_debug line, then run the game and check if the errors have already been emittet when you are at the debug line.

(you can add a debug point by clicking to the left of a line.)

you can also try to print out the result of the change_scene command like this:

print("changing scene error message: ", get_tree().change_scene_to_packed(new_scene))

this should print out the error Message that gets thown by the change scene command. (This might very well be OK in which case there is no error)

I don’t really know what causes your errors so I am just trying some stuff to see if we can get some useful information.

that is fascinating investigation, almost like a true crime :slight_smile:

exiting tree
At: res://scripts/master.gd:56:_exit_tree()
changing scene error message: 0

This is what happened when I added the line you suggested.

I also tried removing some of the scenes which are part of the main scene . It seems to be descreasing the number of 21.

Unit Overlay is an instantianted scene and has 3 signals here. When I disconnect those signals, nothing happens. I still have 21 errors.
But when I drop entire scene, the number of errors goes to 17 (which is actually 16, because 1 new appears) . This does not make any sense :slight_smile:

Found the culprit, but NO IDEA what to do now.

This seems to be issue with the built-in class or the wrapper library built on it. It seems to be sending this “changed” signal.
When I try to change scene and TileMapLayer is one of this scene children, it will bombard me with those signals, and even call deferred on the change scene does not help.

issue has been fixed by upgrading the addon I have been using for TileMapLayer to the newest version. Author fixed the issue recently :slight_smile:

1 Like

this is probably related.

yes , looks like it. thanks for help :slight_smile:

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.