This is just like the example that I have. Basically the var "progress" doesn't do nothing. what's wrong?

Isn't this the same issue you were having in this post? I'm not sure why you made a new topic for this, unless I am missing something (which is entirely possible).

Do you get any errors in the debugger when you run the scene that has this code? There might be an error that can help narrow down what is going on. Additionally, is there a reason you are calling call_deferred rather than just setting the maximum directly? I might suggest just using progress.set_max(total) or progress.max = total (If max is a property) and see if that fixes the issue.

@TwistedTwigleg said: Isn't this the same issue you were having in this post? I'm not sure why you made a new topic for this, unless I am missing something (which is entirely possible).

Do you get any errors in the debugger when you run the scene that has this code? There might be an error that can help narrow down what is going on. Additionally, is there a reason you are calling call_deferred rather than just setting the maximum directly? I might suggest just using progress.set_max(total) or progress.max = total (If max is a property) and see if that fixes the issue.

I dont have any errors, further more this code is a script that I found on the docs and it works, so there is no problem about "called_reference", but not once implemented in my project.

If I delete all the lines with the progressbar ("progress") it works but of course without showing me the progressbar.

So, I dont have any errors :(

Probably a stupid suggestion, but are you calling_thread_load() from another node before $Progress has loaded and is ready?

Have you tried: 1. putting that code in _ready() and seeing if it works? 2. putting a break, and seeing if progress is null or the correct object

@Adz said: Probably a stupid suggestion, but are you calling_thread_load() from another node before $Progress has loaded and is ready?

Have you tried: 1. putting that code in _ready() and seeing if it works? 2. putting a break, and seeing if progress is null or the correct object

I did it and it's the same behaviour, but of course. This code is an asset in godot website and it works. The problem is about the progress node that I don't understand why doesnt respond

This script is inside the Singleton, does this may change something?

Ah yes, if it's in the Singleton > @"K-Storm-Studio Ltd" said:

so basically this is the example I found in the asset library in Godot: https://godotengine.org/asset-library/asset/530

Even a simple progress.hide() command doesnt work

I'm not aware of a progress.hide() function. Do you mean progress.visible = false?

@"K-Storm-Studio Ltd" said:

@Adz said: Probably a stupid suggestion, but are you calling_thread_load() from another node before $Progress has loaded and is ready?

Have you tried: 1. putting that code in _ready() and seeing if it works? 2. putting a break, and seeing if progress is null or the correct object

I did it and it's the same behaviour, but of course. This code is an asset in godot website and it works. The problem is about the progress node that I don't understand why doesnt respond

This script is inside the Singleton, does this may change something?

Did you try putting a break at the progress.call_deferred line? When you hover over progress at that line, does the tooltip show you a object or null?

@Adz said:

@"K-Storm-Studio Ltd" said:

@Adz said: Probably a stupid suggestion, but are you calling_thread_load() from another node before $Progress has loaded and is ready?

Have you tried: 1. putting that code in _ready() and seeing if it works? 2. putting a break, and seeing if progress is null or the correct object

I did it and it's the same behaviour, but of course. This code is an asset in godot website and it works. The problem is about the progress node that I don't understand why doesnt respond

This script is inside the Singleton, does this may change something?

Did you try putting a break at the progress.call_deferred line? When you hover over progress at that line, does the tooltip show you a object or null?

I cant break the function, it is not a loop. I put a pass however I dont get anything in the Output message

I think they mean a breakpoint, so execution will freeze there and allow you to walk through the code using the debugger.

Looking at the code in the documentation, I wonder if the issue is actually the while true loop, rather than the progress bar. I think it could be that the code gets stuck in a semi-infinite loop, taking enough processes that the progress bar does not have time (or resources) to visually update. With the exception of the progress bar not updating, does the rest work as expected? Does the resource load and the progress bar update (even if the min/max is not in the right range)?

Also, what happens if you add print(total) right before you call call_deferred on the progress bar? Maybe that will help shed light on what is causing the issue.

@TwistedTwigleg said: I think they mean a breakpoint, so execution will freeze there and allow you to walk through the code using the debugger.

Looking at the code in the documentation, I wonder if the issue is actually the while true loop, rather than the progress bar. I think it could be that the code gets stuck in a semi-infinite loop, taking enough processes that the progress bar does not have time (or resources) to visually update. With the exception of the progress bar not updating, does the rest work as expected? Does the resource load and the progress bar update (even if the min/max is not in the right range)?

Also, what happens if you add print(total) right before you call call_deferred on the progress bar? Maybe that will help shed light on what is causing the issue.

I did it and it prints : 2

Then, the main function that is been called is that one:


    func load_scene(path):
    	thread = Thread.new()
    	thread.start( self, "_thread_load", path)
    	raise() # Show on top.
    	progress.visible = true

Here I got an error: "Invalid set index 'visible' on base (null instance) with value of type 'bool'"

Hmm, wait, so the issue is the progress var is not visible? If so, the issue may not be in the call_deferred code, but in the recent code snippet you posted.

The error you are getting, "Invalid set index 'visible' on base (null instance) with value of type 'bool'", is trying to say that the variable progress is null, not a TextureProgress node and so it cannot set the visible property. You need to assign the TextureProgress node to the progress variable so you can chance its visibility.

@TwistedTwigleg said: Hmm, wait, so the issue is the progress var is not visible? If so, the issue may not be in the call_deferred code, but in the recent code snippet you posted.

The error you are getting, "Invalid set index 'visible' on base (null instance) with value of type 'bool'", is trying to say that the variable progress is null, not a TextureProgress node and so it cannot set the visible property. You need to assign the TextureProgress node to the progress variable so you can chance its visibility.

I'm gonna copy everything from the original script (that works) . How can I assign the TextureProgress node to the progress?

@"K-Storm-Studio Ltd" said:

@TwistedTwigleg said: Hmm, wait, so the issue is the progress var is not visible? If so, the issue may not be in the call_deferred code, but in the recent code snippet you posted.

The error you are getting, "Invalid set index 'visible' on base (null instance) with value of type 'bool'", is trying to say that the variable progress is null, not a TextureProgress node and so it cannot set the visible property. You need to assign the TextureProgress node to the progress variable so you can chance its visibility.

I'm gonna copy everything from the original script (that works) . How can I assign the TextureProgress node to the progress?

Depends on where the node is in the scene tree, but something like progress = get_node("TextureProgress") or progress =$TextureProgress

@TwistedTwigleg said:

@"K-Storm-Studio Ltd" said:

@TwistedTwigleg said: Hmm, wait, so the issue is the progress var is not visible? If so, the issue may not be in the call_deferred code, but in the recent code snippet you posted.

The error you are getting, "Invalid set index 'visible' on base (null instance) with value of type 'bool'", is trying to say that the variable progress is null, not a TextureProgress node and so it cannot set the visible property. You need to assign the TextureProgress node to the progress variable so you can chance its visibility.

I'm gonna copy everything from the original script (that works) . How can I assign the TextureProgress node to the progress?

Depends on where the node is in the scene tree, but something like progress = get_node("TextureProgress") or progress =$TextureProgress

I'm sorry but I cant understand where should I put this line of code. This is my project This line calls the function below

BackgroundLoading.load_scene(scenetToLoad)

func load_scene(path):
	thread = Thread.new()
	thread.start( self, "_thread_load", path)
	raise() # Show on top.
	progress.visible = true

What node is this attached to and what does the scene tree look like? If the node this script is attached to has a child called "TextureProgress", then all you need to do is add progress = get_node("TextureProgress") before line 5.

Ultimately you just need to add the code before you call the load_scene function or before line 5 in the load_scene function.


Edit: Looking at the picture in the OP, it looks like its attached to the node called BackgroundLoader, which does have a child called Progress. In that case, what you need to do is add progress = get_node("Progress") before line 5 in the load_scene function and that should, fingers crossed, fix the issue where it says you cannot set visible on a null instance.

@TwistedTwigleg said: What node is this attached to and what does the scene tree look like? If the node this script is attached to has a child called "TextureProgress", then all you need to do is add progress = get_node("TextureProgress") before line 5.

Ultimately you just need to add the code before you call the load_scene function or before line 5 in the load_scene function.


Edit: Looking at the picture in the OP, it looks like its attached to the node called BackgroundLoader, which does have a child called Progress. In that case, what you need to do is add progress = get_node("Progress") before line 5 in the load_scene function and that should, fingers crossed, fix the issue where it says you cannot set visible on a null instance.

Nothing, I've just tried as below and even moving that line of code... same error


func load_scene(path):
	progress = get_node("Progress")
	thread = Thread.new()
	thread.start( self, "_thread_load", path)
	raise() # Show on top.
	progress.visible = true

PrograssBar has been declared this way:

onready var progress = $Progress

What if you call progress.visible right after progress = get_node(“Progress”)? Outside of that, I am really not sure. My guess is something with the background loading stuff is interfering, but I have not really done enough background/thread loading stuff in Godot to know.

@TwistedTwigleg said: What if you call progress.visible right after progress = get_node(“Progress”)? Outside of that, I am really not sure. My guess is something with the background loading stuff is interfering, but I have not really done enough background/thread loading stuff in Godot to know.

ok do you know what I see? I've written a simple code to list all the subnodes in the scene (BarckgroundLoader) Basically the script reveals me that the focus is still and rightly on the page which call the BakcgroundLoader scene + script. But the problem is that the progressbar is on the BackgroundLoader tscn that's why I think it doesn't find the control.

So what can I do in this case?

ok so... doing this:

get_tree().get_root().get_node("MainScene2D").get_node("BackgroundLoader").get_node("Progress").visible = true

it works! And in the backgroundLoader.gd I have deleted the variable progress. It creates me issues! I dont know why, so now. I would like to optimize this call, which is the best way for you?