How to switch scene to another scene. Thanks so much :)

Godot Version

4.2.2

Question

hi i need to change scene to another scene i have 3 scene to switch but i want to use one script is it possible, how can i do it and how can i free my current scene before i transport to another scene. Thanks so much :blush:

I’m going to guess you’re looking for more than the usual

	get_tree().change_scene_to_file("res://scenes/scene2.tscn")
1 Like

I do this by creating a Globals class and adding it to the autoload. I then add a method to the Globals for switching scenes. That way the global node can handle unloading your current scene and then loading the new one. You can also use the await keyword to wait for the next frame before loading the new scene after unloading the old one.

2 Likes

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