My problem is that during scene transitions, the default Godot screen is displayed. I found out that this happens when something is placed in autoload, and it gets fixed when I remove it. Do you have a solution that allows me to keep it in autoload but still transition to another scene without issues?
Version Godot = 4.3
It might be helpful to have a little code snippet that shows what your scene manager code looks like so that we have more context on whats going on with your code.
For reference autoloading a script doesn’t get unloaded when calling a scene change (via change_scene_to_file()
or change_scene_to_packed()
) you can follow this link to the documentation for more information on how that works.
That means if your autoload script is adding something into the scene tree, it could be that your main scene is simply rendering on top of it, hiding it normally and when you go to transition your scene, deleting the current scene and creating a new one, you momentarily see what the autoloaded script adds to the tree before the new scene is created.
My code:
var next_to_scene := ""
var prograss:Array
func load_scene(path := "",timer := 0.5):
next_to_scene = path
ResourceLoader.load_threaded_request(next_to_scene)
await get_tree().create_timer(timer).timeout
ResourceLoader.load_threaded_get_status(next_to_scene,prograss)
if prograss[0] >= 1.0:
prograss[0] = 0.0
get_tree().change_scene_to_packed(ResourceLoader.load_threaded_get(next_to_scene))
Is this scene manager the autoloaded script? I’m not sure what the problem could be besides maybe an issue with how the ResourceLoader.load...
is being called.
I think that ResourceLoader.load_threaded_get_status(...)
is supposed to run alongside _process()
or _physics_process()
or any method that runs each frame, which should allow your load to trigger properly (once progress hits 1.0
) as opposed to waiting on a timer timeout.
If load_scene()
is being called within your code once, and the scene doesn’t load in time (your default time is 0.5
seconds) maybe that’s causing issues in the code?
I would suggest debugging by incrementing your timer
value to a larger and larger number until the scene loads properly to see if that’s the issue to start. But I think adding the load_threaded_get_status()
to a call that happens within each engine frame so that when progress hits 1.0
you can execute the scene transition might be helpful.