The Godot Q&A is currently undergoing maintenance!

Your ability to ask and answer questions is temporarily disabled. You can browse existing threads in read-only mode.

We are working on bringing this community platform back to its full functionality, stay tuned for updates.

godotengine.org | Twitter

0 votes

I am using C# and have been able to load a scene with ResourceLoader.LoadInteractive() in its own thread. This has been great.

However, once I get this huge scene loaded, when I use the get_tree().change_scene_to(newScene), the game freezes for a few seconds.

I know this is just adding newScene as a child. It is blocking the main thread. How do I change scenes asynchronous or without freezing the game?

Godot version 3.5.2
in Engine by (422 points)

1 Answer

0 votes

idk if it works in godot 3 but you can try: gettree().changescenetofile. Not sure if that will fix anything.

what I would recommend is adding a unique bootsplash that shows the player that the scene is loading in. I feel like in games its not easy to seamlessly move to a new scene especially if the scene is huge like you said. the engine needs time. But with a loading screen it would signal to the player whats going on instead of them thinking the games crashing.

by (33 points)

I do have a splash screen with a progress bar. I can asynchronously load the scene into Godot and show the progress. The problem is, once it's loaded into the memory, I need to add the scene as a child "add_child()" and THIS also is taking a few seconds. I need to know how to add a child asynchronously.

are you loading the child in the scene but off screen or out of view? this might not be to much help but if you are you could add a visibilty enabler node. it will turn visibillty off when the node is off screen and it signifactly reduces the fps lag on your game. I recommened adding this to all your nodes and it will always work in the background helping reduce the lag. Godot has to constantly check what is on screen and it will freeze things up if theres to many.

I once created a cell simulation game that had cells reproduce exponentially. this caused massive freeze times when the childs spawned in but adding the visibilty enabler stopped the freeze.

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.