Hi folks, struggling hard with integrating a Loading scene in between the main menu & gameplay scenes of my game. I'm using a singleton (GameState) to hold the path of the nextScreen and then switching to the Loading Scene which loads the next scene (specifically: I am trying to load my Tutorial scene, which contains the Playspace & GameEngine)

var loading_status
var progress : Array[float]
@onready var nextScreen = GameState.nextScreen
func _ready():
ResourceLoader.load_threaded_request(nextScreen)

func _process(delta):
loading_status = ResourceLoader.load_threaded_get_status(nextScreen, progress)
match loading_status:
ResourceLoader.THREAD_LOAD_IN_PROGRESS:
progress_bar.value = progress[0] * 100*2 # Change the ProgressBar value
ResourceLoader.THREAD_LOAD_LOADED:
progress_bar.value = 100
if $Timer.time_left == 0:
get_tree().change_scene_to_packed(ResourceLoader.load_threaded_get(nextScreen))
ResourceLoader.THREAD_LOAD_FAILED:
print("Error. Could not load Resource")

When I run the exported file on Android, the progress bar stays at 0 and then the game crashes. Once, it even forced my phone to restart. The code seems to work on my computer (Mac). But even then, some of the signals & on_ready fxns of the loaded scene do not seem to run? Would really appreciate some help as I am very confused!

  • xyz replied to this.

    wizwon For start, prior to initiating the load, check if the resource at given path exists using ResourceLoader::exists()

      xyz Hi, I added this check, but no change, still crashing on mobile and ready functions of some children of the scene are not initialized properly

      • xyz replied to this.

        wizwon Make a test project that only loads this resource.

        Like using the resource loader or just load the scene normally? Because if I just load the scene without the resource loader it works fine

        • xyz replied to this.

          wizwon Isolate the problem. Load it like you're loading it when it crashes but make a project that does only that. That way you can determine if that's really the cause.

          In general, when you have weird bugs, always try to isolate them. Divide and conquer tactics work well when dealing with bugs.