Gapless Scene Change

i would rather make something like a switch scene function that a core/main controller has, so it doesnt need to call change_scene_to_file() to remove whole scene. with this you can add loading etc while switching scene to another without delay

something like this:

core.gd

func switch_scene(scene_path: String,level=-1):
	var current_scenes = scene_node_container.get_children()
	var scene_count: int = current_scenes.size()
	
	if (scene_count > 0):
		loading_panel.visible = true
		
		
		await get_tree().create_timer(0.1).timeout
		
		for child in current_scenes:
			scene_node_container.remove_child(child)
			child.queue_free()
		
		var new_scene = load(scene_path).instantiate()
		scene_node_container.add_child(new_scene)

		await get_tree().create_timer(0.4).timeout
		
		loading_panel.visible = false

image

2 Likes