Hi! I'm trying to implement a loading screen for my 3D game, and I've been having issues. I've been looking around for a few hours for code examples and it seems that everything i've seen is essentially using something like this:
@onready var progress_bar:ProgressBar = $ProgressBar
@onready var progress = []
@onready var scene_load_status = 0
@export var scene:String
func _ready():
set_process(true)
scene=Global.sceneHeading
await get_tree().create_timer(1.0).timeout
ResourceLoader.load_threaded_request(scene,"",true)
func _process(_delta):
scene_load_status = ResourceLoader.load_threaded_get_status(scene,progress)
progress_bar.value = progress[0] * 100
if scene_load_status == ResourceLoader.THREAD_LOAD_LOADED:
get_tree().change_scene_to_packed(ResourceLoader.load_threaded_get(scene))
queue_free()```
Unfortunately, this has issues. The loading bar never moves, and I also have some text being animated by an animation player that stops as soon as loading starts. Both are set to always process.
Additionally, I get a lot of errors. Sometimes things randomly aren't loaded or toss up an issue saying that there was a problem loading, or an error says there was an attempt to free an invalid ID. Materials will say "material_casts_shadows: Condition "!material" is true. Returning: true" among other things. Not sure what that means?
I went digging around Github and saw that there are maybe issues with the loader? But I am unsure. Is this a common error? Or is something about this loading code wrong?