reloading a scene

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By JakeCarbine

hello I am trying to reload a my pong game when the game is over here is my code where I execute that behavior:

if Input.is_action_pressed("ui_reset")&&endGame:
	get_tree().reload_current_scene()

here is the error I get in my debugger:

E 0:00:30.599   reload_current_scene: Condition "!current_scene" is true. Returned: ERR_UNCONFIGURED
  <C++ Source>  scene/main/scene_tree.cpp:1319 @ reload_current_scene()
  <Stack Trace> Level.gd:36 @ _process()

it traces back to that same line. please could you assist me.

:bust_in_silhouette: Reply From: Help me please

better if you try to change scene again to the current scene

get_tree().change_scene("res://###")

That’s how it’s implemented in engine code. So it is hardly possible to give a better answer

Error SceneTree::reload_current_scene() {
	ERR_FAIL_COND_V(!current_scene, ERR_UNCONFIGURED);
	String fname = current_scene->get_filename();
	return change_scene(fname);
}

Mak | 2021-04-28 15:33

:bust_in_silhouette: Reply From: Suleymanov

Try var _reload = get_tree().reload_current_scene() instead.