Hello,
I'm new to godot and am trying to develop a multiplayer fps game (a dream).
My problem is the following: I have 4 players (1 server, 3 clients) Server also participates as a player.
When one of the clients disconnects, either by closing the window or by using the button, the other clients start to control each other, regardless of having deleted the character of the disconnected client or not.
The remaining clients can see the server character moving, but the clients remain immobile to the server.
Apparently out of sync.
How to disconnect client correctly without causing desync or any other bizarre error?
Please help me.
Here's a code summary of how I generate the characters:
func _ready():
add_child(team_players)
add_child(team_bots)
team_bots.name = "team_bots"
team_players.name = "team_players"
rpc("spawn_players", Onload.local_player_id)
if get_tree().is_network_server():
rpc("spawn_enemies", max_ini)
remotesync func spawn_players(id):
var spw_char = chr.instance()
spw_char.name = str(id)
team_players.add_child(spw_char)
spw_char.set_network_master(id)
if spw_char.is_network_master():
spw_char.camera.current = true
randomize()
spw_char.global_transform.origin = get_spawns[randi() % get_spawns.size()].global_transform.origin
Thank you very much in advance.