Godot Version
4.5
Question
I have a game where clients connect to a server, make some selections and then load into a level scene. The server waits for all players to say “ready” in the scene’s _ready() function.
Once all players are ready, the server runs a function to loop through and spawn all players with $MultiplayerSpawner.spawn(id), which spawns nodes on all clients and are synchronized by each player scene’s MultiplayerSynchronizer, synchronizing things such as position.
What happens if one of the client’s receives the MultiplayerSpawner packet late and receives a MultiplayerSynchronizer event first? I know that receiving commands from a MultiplayerSynchronizer without a node existing will cause the code to break, so I would like to know if it internally handles race conditions to prevent a MultiplayerSynchronizer code from running like this. Any suggestions for best practices?
Edit: Meanwhile to be safe I set all MultiplayerSynchronizer’s public visibility to false at start and have each client send an rpc between themselves after receiving a spawn event to let them know when it’s safe to start synchonizing via set_visibility_for().