Search code examples
nodesgodotmultiplayergodot4

One-time node data transfer in Godot multiplayer


MultiplayerSychronizers keep data updated between players continuously as a game goes on, but is there a way to transfer entire nodes to all the connected clients exactly once? I have a MultiMeshInstance3D that I want to generate once and then never update again, but I don't want to have to individually generate it on each client's computer. Is there a way I can make an override @rpc version of add_child or something?

The MultiMeshInstance3D is a PackedScene, if that's pertinent. I tried adding a MultiplayerSychronizer child that synced the multimesh variable of scene root, but it threw an error from a .cpp file from deep within the base Godot files:

E 0:00:13:0803 get_node: Node not found: "Manager/GameBoard/Map/TileMap/MultiplayerSynchronizer" (relative to "/root"). <C++ Error> Method/function failed. Returning: nullptr <C++ Source> scene/main/node.cpp:1364 @ get_node()


Solution

  • No, you cannot transfer nodes between clients. At best, you could create custom functions that take the necessary node data and reconstruct it on the receiving end, but since in my case the MultiMeshInstance3D is already being generated by a function, it would be only a little payoff (slightly less computing) for the downside of having to write another function and handle the calls for it. It's much more efficient to have each client generate the MultiMeshInstance3D themselves.