0 votes

Hello ! I'd like to get the progress of the preloading of my ingame scene to update my loading bar. But this line seems to be the problem :

var progress = float(thread.get_stage()) / thread.get_stage_count()

Here is the code :

onready var thread = Thread.new()
onready var current_scene =  get_node("/root/titlescreen")

func load_nextscene():
    thread.start(self,"prep_scene", ResourceLoader.load_interactive("res://scenes/ingame.tscn"))


func prep_scene(interactive_ldr):
    while (true):
        var err = interactive_ldr.poll();
        if(err == ERR_FILE_EOF): 
            call_deferred("_on_load_level_done");
            return interactive_ldr.get_resource();

        elif(err == OK):
            update_progress()

func update_progress():
    var progress = float(thread.get_stage()) / thread.get_stage_count()    
    get_node("/root/titlescreen/ProgressBar").value = progress;

I tried changing "thread" with "thread.interactiveldr" and "interactiveldr" but none worked :/ thanks !

in Engine by (245 points)

Please log in or register to answer this question.

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 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 webmaster@godotengine.org with your username.