You might notice that when the game starts, the host’s player is spawned at the correct spawn point, but the client’s player is spawned at the origin.
The bug happens due to the multiplayer_authority… the server cannot set the position of the client player.
The easiest fix I could find is to set the MultiplayerSpawner.spawn_function
property and use the MultiplayerSpawner.spawn()
method to run code on both the client and host:
@export var player_spawner: MultiplayerSpawner
...
func _enter_tree():
player_spawner.spawn_function = spawn_player
...
func add_player(id):
player_spawner.spawn(id)
func spawn_player(id):
var player_instance = player_scene.instantiate()
player_instance.position = get_spawn_point()
player_instance.name = str(id)
return player_instance