func spawn_player(id: int):
var inst = spawnable_player.instantiate()
inst.player = id
spawn_node.add_child(inst, true)
inst.global_position = spawn_point_parent.get_children().pick_random().global_position
which calls
# Set by the authority, synchronized on spawn.
@export var player := 1 :
set(id):
player = id
print("set player authority on character input component")
# Give authority over the player input to the appropriate peer.
$CharacterInput.set_multiplayer_authority(id)
The authority id is updated on the server but not on the client. If anyone could help me figure out what have I missed I would be very grateful.
Turn your spawn_payer function into a custom spawn function for the multiplayer spawner to use. ( Although the random spawn location should only happen on the server)
The basic setup of a multiplayerspawner can only instantiate a scene to its defualt settings and set its name.
By using a multiplayer spawner’s custom spawn you can perform some client side setup. But most usually opt to setting the node name to the peers multiplayer id and reading that node name, on instantiation, to set authority as a quick workaround.
You could also try to get a multiplayer synchronizer to sync the player property, containing the peer’s multiplayer id, with on spawn to do something similar.
Ah I missed the setting of the name was important and the replication of the player field… I thought from the docs that multiplayer spawner would synchronize the multiplayer authority itself but I misunderstood, thanks penny!