I’m having an issue where I want to have Godot switch my game scene to a new scene and then set a few parameters on the new scene to affect where some objects are in the scene. Unfortunately, immediately after calling get_tree().change_scene_to_file(), the tree’s current_scene is null. I also tried waiting for the next process_frame event, but that’s not enough to ensure the scene has been added to the tree. There also doesn’t seem to be any signal to indicate that the new scene has been loaded and is ready to go. And you are not allowed to simply set current_scene to a node.
How can I get the scene as soon as possible after it is loaded so I can make some changes to it?
The timer is not necesary but i felt like it was so abrupt to switch already on the next frame. Felt more natural with a tiny moment of slowdown first.
I don’t think using a timer is a good idea. You have no guarantee that the scene will be loaded after that many seconds. You may also be needlessly waiting too long. You can also have different wait times on different machines running the code. It would be better to have some way to know precisely after the scene changes.
If you have no problem blocking the main thread, then use load to retrieve a PackedScene blocking the main thread and then after use change_scene_to_packed. Wait a single frame and then you should be able to access the current_scene.