godotengine / godot

Godot Engine – Multi-platform 2D and 3D game engine
https://godotengine.org
MIT License
90.75k stars 21.12k forks source link

MultiplayerSynchronizer throwing Error when connected client is not in same scene as Host #70296

Open baumland opened 1 year ago

baumland commented 1 year ago

Godot version

4.0-Beta8

System information

Windows 11

Issue description

MultiplayerSynchronizer throws Error E 0:00:06:0199 _send_sync: Condition "!sync || !sync->get_replication_config().is_valid() || !sync->is_multiplayer_authority()" is true. Continuing. <C++ Source> modules/multiplayer/scene_replication_interface.cpp:647 @ _send_sync() if connected client is not in the same scene as the Host (and the Host's Scene has an MultiplayerSynchronizer)

Steps to reproduce

Code handling Connecting: image image

Scene host changes to after connecting: image

Minimal reproduction project

BugTest.zip (Contains GDScripts and c# source files)

Calinou commented 1 year ago

cc @Faless

mojoyup commented 1 year ago

I can confirm this for beta 10 as well. Have you tried adding a node between the root node and the synchronizer? Does the synchronization still work even with the error? And last, it is only on server side correct? Are there any client side errors related?

NOTE: I have this error when the client is ALSO IN the same scene as the host peer. I am working on trying to add certain nodes to the replication process to see if a certain scene changes things due to maybe not needing to be replicated by that node. WIll watch :)

mojoyup commented 1 year ago

@baumland So, it seems, by the project, that you don't have any sync vars for the multiplayerSync node. That could be the issue. It may be looking for something in the backend code that doesn't check for errors if nothing is there. Adding a variable to it stopped the error for me on your test project. Can you confirm and test maybe different nodes as well? Ill do the same

NOTE: Unless you change the scene also to the same as the host, you will get an error as well saying that the synchronizer can't be found (because it's in the multiplayerscene node).

baumland commented 1 year ago

Tracking a property of another object seems to fix this issue. Still, throwing any error if it isn't tracking anything could limit potential dynamic tracking.

mojoyup commented 1 year ago

Tracking a property of another object seems to fix this issue. Still, throwing any error if it isn't tracking anything could limit potential dynamic tracking.

Agreed. It seems that an implementation of error checking or making this a warning instead may be needed? Warning I say mainly because it doesn't actually affect the synchronization of the node that I can see. So that brings up a question then. Are you trying to synchronize the scene? Or just have it try to do that for everything in the scene?

akien-mga commented 1 year ago

Can you still reproduce this in 4.0.3 and 4.1-beta3 or later?

CC @godotengine/network

Faless commented 1 year ago

Yes, this is still valid, change_scene doesn't work well with multiplayer sessions. See also https://github.com/godotengine/godot/issues/68407#issuecomment-1445858643