Godot Version
Godot v4.2.2.stable.arch_linux
Question
Hi there, I got my game freezing when changing a part of my scene tree. I got a transition running during that loading time using an animationplayer(also tried _progress in one script - same result).
The animation player is basically controlling an alphavalue for a shader getting from 0 to 1 in a short time.
I got the bug down to a part of my functions:
I am connecting the signal of when the main part of the level is unloaded:
"
levelnode.tree_exited.connect(load_new_level)
"
Then I am calling this function:
"
func unload_level() ā void:
print(āLEVEL IS UNLOADEDā)
onload nodes under %Worldviewport
if (is_instance_valid(levelnode)):
levelnode.queue_free()
%Transition/AnimationPlayer.play(āfade outā)
levelnode=nul
"
%Transition/AnimationPlayer.play(āfade outā) ā calling the fading animation which is not seen until after the freeze. I can put
await get_tree().create_timer(X).timeout
to see X seconds from my animation before the freeze. Freeze is about 1-3seconds. I donāt care that the game loads for 1-3seconds. Does not matter. But the Animation should not pause/freeze during that loading time.
So how to unload part of my level and still have my transition playing while doing it?
You canāt queue freeing it before youāre done with it, itāll be freed at the end of the frame, instead make it call some finishing method at the end of the animation, or wait for the animation to end
1 Like
Thanks for reading and giving it a shot.
The animation is NOT a part of the nodetree that is queued free. It freezes for 2-3seconds and runs fine afterward
ROOT
|-level
|-animation
|-other stuff
only level is queued free.
try load new level first, then free self
Did you ever find a solution to this? Iām having the same issue, where I have a large level that Iām removing from my scene tree, with a loading screen running. Despite using a thread to queue_free the level, the animation of the loading screen still freezes.
Same as OP, I do not care if it takes a few seconds to remove the level. It is just frustrating to not be able to get a simple animation loop to play without freezing, even using threads. Iām currently down a dumb rabbit hole of removing sections of the level with set timer delays to try and get the thing to work without freezing the animation.
Not a very good solution. I donāt remember exactly. It was some workaround like throwing prints all over the place, finding out where it freezes and since it is a transition I changed the transition to start after the freeze. Never really got it not to freeze.
But since it is a transition between scenes it now at least looks acceptable.
Ah thatās a bummer. Yeah it seems silly that I can create separate threads specifically to remove an old level and load the new one, and leave the main thread for literally just a little animation, and it still freezes and lagsā¦