Reload scene debug error

I am using Godot v4.2.1 and was getting an error in the debugger each time get_tree().reload_current_scene() was called.

This could be fixed by replacing it with get_tree().call_deferred("reload_current_scene")

Source:

A similar fix for the couple following lectures:

get_tree().change_scene_to_file(next_level_file)
can be changed to:
get_tree().call_deferred("change_scene_to_file", next_level_file)

tween.tween_callback(get_tree().reload_current_scene)
can be changed to:
tween.tween_callback(get_tree().call_deferred.bind("reload_current_scene"))

tween.tween_callback(get_tree().change_scene_to_file.bind(next_level_file))
can be changed to:
tween.tween_callback(get_tree().call_deferred.bind("change_scene_to_file", next_level_file))

2 Likes

Thanks! Was driving me crazy… as to why it wasn’t happening to the instructor.

To add on to this, if you are using C#, as of Godot 4.2, you need to use the GDScript naming syntax for the method string you pass to CallDeferred. So instead of “ReloadCurrentScene” use “reload_current_scene”.

GetTree().CallDeferred("reload_current_scene");

C# implementation is still being worked on, so this will likely be fixed in future versions of Godot.

From this doc: https://docs.godotengine.org/en/stable/tutorials/scripting/c_sharp/c_sharp_basics.html#current-gotchas-and-known-issues

Privacy & Terms