#[4.3 stable] How to properly give authority over to a player using MultiplayerSpawner?

1 messages · Page 1 of 1 (latest)

fast pier
#

Hello,
I'm using MultiplayerSpawner to spawn standalone MultiplayerSynchronizer for every new player in the session. The server sets authority based on the uid, and it works, but gives me this error:

E 0:00:17:0292   on_replication_start: The MultiplayerSynchronizer at path "/root/Level/PlayerInputs/2096471382" is unable to process the pending spawn since it has no network ID. This might happen when changing the multiplayer authority during the "_ready" callback. Make sure to only change the authority of multiplayer synchronizers during "_enter_tree" or the "_spawn_custom" callback of their multiplayer spawner.
  <C++ Error>    Condition "pending_sync_net_ids.is_empty()" is true. Returning: ERR_INVALID_DATA
  <C++ Source>   modules/multiplayer/scene_replication_interface.cpp:243 @ on_replication_start()

I've tried setting the authority in _enter_tree inside the synchronizer's scene but this doesn't work at all, and besides that this error still appears. Also, I couldn't find "_spawn_custom" callback thing in the MultiplayerSpawner. Any help?

#

[4.3 stable] How to properly give authority over to a player using MultiplayerSpawner?

verbal plank
#

The answer is you shouldn’t, not directly. Nodes spawned by the Spawner are expecting to stay server authoritative. That said, spawning a Node, you can then set the authority of its children to the client without running into issues.

So basically add an intermediate node between the Spawner and the synchronizer.

#

_spawn_custom was replaced by spawn_function in later betas

fast pier
#

@verbal plank thanks for the reply!

So basically I'm doing it like this right now:

root
  PlayerInputs (Node)
    PlayerInputSynchronizer (MultiplayerSynchronizer)

but I should be doing it like this:

root
  PlayerInputs (Node)
    PlayerSynchronizer (Node)
      PlayerInputSynchronizer (MultiplayerSynchronizer- child of the Node above)

and spawn PlayerSynchronizer (Node) via MultiplayerSpawner, wchich is given UID as the name, and then, say on _enter_tree (or via uid setter method) set multiplayer authority on it's child - the PlayerInputSynchronizer (MultiplayerSynchronizer). Is that right?

Yeah, I know, I have MultiplayerSynchronizers as loose-nodes, not children of specific player entities.

verbal plank
#

Yup that should work from a node tree perspective!