Loading screens with MultiplayerSpawner

Godot Version

4.3

Question

I need to spawn levels with MultiplayerSpawner to avoid synchronization problems, but it uses ResourceLoader.load internally which hangs the game. I need to use a loading screen to load asynchronously.

What I tried:

  • Spawning a loading screen instead of level. This leads to “node not found” errors when host loads scene faster than clients, which means MultiplayerSynchronizers cannot syncronise spawn properties.

  • Loading ALL levels to memory before starting game. This works but it increases loading times 20 seconds on my machine and wastes a lot of memory, not worth using

  • Using rpcs to make sure all peers have scene loaded. This makes everyone wait for no reason, and doesn’t work when a player joins the game later.

  • Running MultiplayerSpawner in a thread group. This doesn’t make any difference.

Is there a workaround?

I have been coming aware of this scenario, but haven’t tried any of these approaches.

Maybe what you can do is when a player joins remove all network visibility until they can load the level then start enabling visibility.

Look at the multiplayer API, SceneMultiplayer, and see if you can drop filter or defer spawn and sync packets until peer is loaded.

Thanks for suggestions. I didn’t realize I can use visibility for spawners too.

I just tried changing network visibility. Level itself spawns without errors, but nested spawners do not work properly. They spam “cache not found” errors and spawn with a few frames delay, but I cannot despawn anything from nested spawners. Probably related to this bug: Multiple MultiplayerSynchronizer's under MultiplayerSpawner with different public_visibility states prints error · Issue #68508 · godotengine/godot · GitHub. I tried dummy sycnhronizer workaround from that page but it re-enables public visibility of MultiplayerSpawner.

I couldn’t find anything related in MultiplayerAPI and SceneMultiplayer other than object_configuration_add. Looks like MultiplayerSpawner calls it internally to track a node. I tried removing object configuration to see if I can delay spawning with it, but it despawns scene from all peers when it stops tracking a node.

Oh! That looks like an issue I could try and contribute too.

Yeah the documentation around the multiplayer API is a little strange. If you look at MultiplayerAPIExtension class there is an example of extending the SceneMultiplayer class, and it gives you access to the fundamental API. I haven’t spent a lot of time looking at it to know what’s possible, or the order of operations.