I've used exported file paths to scene files using export (String, FILE) var next_level
and then changing the scene using get_tree().change_scene(next_level)
, but it can still have the issue with circular references.
Depending on how your levels are setup and the naming used, you might be able to programmatically construct the file path and change levels that way. For example, if all of your levels are in a folder called levels
and are named level_x
, where x
is the level number, you could do something like this:
export (int) var current_level_number = 0
func change_level():
get_tree().change_scene("res://levels/level_" + String(current_level_number+1))
Though it has its own set of constraints and design limitations.