Spawn and Despawn Player Between Scenes

Godot Version

V4.3

Question

https://youtu.be/2bJ0y-xcSTY

Hi all, hope you are well.
In my multiplayer game I can have my clients change scenes from a 2D world to a 3D world and have it sync to both the server and all other clients which I am very happy with.

However during this process I encounter some errors which are causing other problems with the rest of the game including player interaction. In the youtube link listed above is a demonstration video which showcases the problem including the scene tree, error messages and relevant code. In the remove_player_character function the player node executes queue_free().

If there is anything I have missed which would assist in diagnosing or solving the problem please let me know and I hope someone will be able to provide assistance. Thanks!

The errors I think relate to the MultiplayerSynchronizer losing its remote node to sync with. I think these can be ignored.

If you want to fix…

There should be a multiplayer spawner that can delete the player. The spawner authority should delete the player, and not the client.

There could be more but let’s try this.

Update:

I changed some code around and now the blocked player functionality from before has been restored and works as intended, hooray.

Although the error still persists and I’m wondering if Godot will “run out of caches” or something as the errors multiply across players and executions. Either way I’d like to solve the error if possible. Image below is the current best running code and their cases.

image
If run on client instance: Works great!, all clients load into the new scene and is updated on all screen including the server
If run on server instance: Doesn’t transfer players

Changing the rpc parameters has little effect. Removing the is_multiplayer_authority() statement causes extra noname players to spawn on client instances for each client. Both cases produce similar errors as the errors mentioned previously. A big part of the functionality is to have the clients control when they would like to change scene from 2D to 3D from their own instance.

This RPC is fine. MultiplayerSpawners just watch a node path for child_enter/child_exit signals. so if the authority of the spawner queue_frees a watched node it will delete it for all clients. (The spawn function is a special case for replication, all that is required is it leaves the tree, on the authority peer, for despawn)

What I believe to be happening is the MultiplayerSynchronizer receiving player updates is deleted before the authority is (which is probably remote peer) and new packets throw the error when it can’t find the node anymore.

Replication_configs used by syncers are cached. (Make sure to use relative property paths when configuring them)

When a spawner deletes a replicating node, I think it does some house keeping to prevent the errors.