godotengine / godot

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

RPC checksum fails when custom MultiplayerAPI is set on SceneTree via set_multiplayer #80604

Open FireCatMagic opened 1 year ago

FireCatMagic commented 1 year ago

Godot version

v4.1.1.stable

System information

Godot v4.1.1.stable - Windows 10.0.19045 - Vulkan (Compatibility) - NVIDIA GeForce GTX 750 Ti (NVIDIA; 31.0.15.3623) - 12th Gen Intel(R) Core(TM) i5-12400F (12 Threads)

Issue description

When setting a custom MultiplayerAPI via the scenetree, the checksum fails unless the other peers have a custom API set as well. The behavior I expected is that since they are both SceneMultiplayer, have the same RPC methods, same nodepaths, that it would work even though the MultiplayerAPI is set to a different one.

Steps to reproduce

I've set up a simple test project with a few variables. image image

Setting the Custom Multiplayer export variable will create a custom multiplayerApi and set it, as the title of this post says: image

Leaving it unchecked won't create the MultiplayerAPI.

Checking server just makes it the server, not a client. image

I exported this project 3 times, with these options selected each time:

Export 1: Server image Export 2: Client image Export 3: Client, Custom MultiplayerAPI image

I feel its easier to explain as a gif: AtiqQ8Zybz

Despite the nodepaths being the exact same, it spits out errors about invalid paths in the console.

Minimal reproduction project

RPCChecksum.zip

Faless commented 1 year ago

When setting a custom MultiplayerAPI via the scenetree, the checksum fails unless the other peers have a custom API set as well.

Well, this is indeed the expected behavior.

Godot MultiplayerAPI requires node paths used for RPCs or synchronization to match across peers.

The paths are relative to the multiplayer root which is the path you set via get_tree().set_multiplayer (/root/ for the default one).

When using custom multiplayer branches your scene tree should look something like:

/root
  main
    Server (custom)
      game
    Client1 (custom)
      game
    Client2 (custom)
      game

Additionally, I strongly advise setting the custom multiplayer during _enter_tree so it happens before the child nodes tree callbacks (as they may include other multiplayer nodes like MultiplayerSpawner or MultiplayerSynchronizer).