-
-
Notifications
You must be signed in to change notification settings - Fork 21.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unexpected behaviour with MultiplayerSpawner after changing scenes (with change_scene_to_*
) via RPC call
#68407
Comments
I'm experiencing the same problem as I tried to add MultiplayerSpawner to my project, where I use get_tree().change_scene_to_file() method to change between lobby and the gameworld scenes. In my another demo project the MultiplayerSpawner works fine when everything is contained under one node and I don't change scenes with that method. Godot version System information I would love a fix or workaround to this problem. |
I'm also experiencing the same issue (beta8/master). I have 2 cases in my testing game:
I can actually replicate the issue of 2. on 1. by adding World on the client after spawning the Players. This does match the behavior of 2. From what I can tell: The MultiplayerSpawner doesn't work on the client if it's added after children are already spawned. |
I've found another case where this can happen. If the client has a |
I fought with what I think is the same underlying problem as OP (at least) last week. As I understand it (take with a grain of salt), the replication interface does some work to map node path strings down to IDs to optimize future communication between the peers. Unfortunately, this "simplify_path" operation seems to ~only happen when a peer first connects. If the client hasn't loaded the to-be-synced tree yet when the connection is established, you get:
Then, when decoding the server's spawn state, the client can't use the simplified node identifier (since it wasn't able to establish it, and may still not have the node in the tree). Thus, you get these for each to-be-spawned object :
In my project, I've hacked around this for now by doing a two-phase start. As long as the client scene loads before the server's MultiplayerSpawner notices the peer has connected, they're able to get the paths simplified on that first sync attempt, and everything is golden after that. |
Ah, more precisely, it's adding the spawnable nodes in the server's _ready (since the client is already connected, if not loaded) that triggers the sync. |
I tried to figure out a good solution for this issue, but it will need to be pushed for 4.1. The problem relies on the deferred nature of I would discourage from using |
This comment was marked as duplicate.
This comment was marked as duplicate.
This comment was marked as duplicate.
This comment was marked as duplicate.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as duplicate.
This comment was marked as duplicate.
This comment was marked as duplicate.
This comment was marked as duplicate.
This comment was marked as duplicate.
This comment was marked as duplicate.
This comment was marked as duplicate.
This comment was marked as duplicate.
This comment was marked as duplicate.
This comment was marked as duplicate.
This comment was marked as duplicate.
This comment was marked as duplicate.
This comment was marked as duplicate.
This comment was marked as duplicate.
This comment was marked as duplicate.
This comment was marked as duplicate.
This comment was marked as duplicate.
This comment was marked as duplicate.
This issue is confirmed, please do not comment to confirm it further. The problem relies on the deferred nature of Please do not use |
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as resolved.
This comment was marked as resolved.
change_scene_to_*
) via RPC call
Important
Bugsquad note: This issue has been confirmed several times already. No need to confirm it further.
Please read #68407 (comment) for a workaround.
Godot version
4.0.beta4
System information
Windows 11 22H2
Issue description
I've setup a simple lobby which will only load both players into another scene once a client connects to the host. After the scene is loaded some subscenes are instantiated on the host and added to a child node in the scene.
What I expect to happen is, the MultiplayerSpawner will spawn the subscenes on the client at the position (0, 0). However it seems that because I am using an rpc call to load the scene for both the host(locally) and client(remotely) the MultiplayerSpawner fails. The code block below is what the debugger returns for the client instance.
The MultiplayerSpawner does sometimes produce the expected results, albeit very infrequently. What baffles me is that I've had a friend test this on their own machine with the same release of Godot and the MultiplayerSpawner seems to work as expected.
I've found that the MultiplayerSpawner behaves as expected if I load the scene manaully for each instance, rather than through an rpc call for both the host(locally) and client(remotely).
Steps to reproduce
To test loading via RPC
To test loading manually
start_game()
on line 12 and 26 in lobby.gdMinimal reproduction project
multiplayer-nodes.zip
The text was updated successfully, but these errors were encountered: