This site is currently in read-only mode during migration to a new platform.
You cannot post questions, answers or comments, as they would be lost during the migration otherwise.
0 votes

i am trying to create a loading screen using the interactive resource loader. I am mainly using the code provided by this example : godot-docs

Everything works for me except the updating progress bar. When i start the function my loading screen pops up but the progess bar doesnt move.
I have tried printing the progress each time the loader polls and i found out it only calls the updateProgress() function after it finished loading everything.

this is the process function:

if loader == null:

if wait_frames > 0:
    wait_frames -= 1

var t = OS.get_ticks_msec()

while OS.get_ticks_msec() < t + time_max:
    var err = loader.poll()
    if err == ERR_FILE_EOF:
        var resource = loader.get_resource()
        loader = null
        game_instance = resource.instance()
    elif err == OK:
        updateProgress() -> **this function only triggers after everything  is loaded**
        print("error during loading")
        loader = null

does anybody know a solution?

thanks and best regards

Godot version 3.2.3
in Engine by (12 points)

1 Answer

0 votes

It seems like your code is calling updateProgress() many times, but all inside the same tick, with no opportunity for your progress bar to visually update.

You can add gaps in your loop by adding a yield(get_tree(), "idle_frame") as the first instruction of your loop. This will allow other things to be processed in between each iteration.

If you have many small loads, you can use OS.get_ticks_msec() to figure out if you have enough time left in your tick (~=16ms) to not yield yet into the next one.

updateProgress() could also be faulty, but it's code is not included in the question. You can add a print to it to see when it is called.

by (2,720 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.