So I have a working online game without any errors, I handle the host disconnections well, but if a client that joined the host disconnects all hell breaks loose. The problem is that if a client disconnects I want it to change the scene to the main menu scene, but I also need to free its player object from the host-side before changing the scene otherwise I get unlimited errors on each frame. BUT if I free it from the host-side I have no way of changing the scene (cannot access that client anymore), it is a vicious circle, did anyone experience this before? how do you handle a client leaving the game? I tried timers and rpc calls to the client so it changes the scene after the freeing but it doesn’t work
SOLVED:
In the RPC that tells the client to change scene, I just had to put the multiplayer_peer to null:
@rpc(“any_peer”)
func _go_back_to_main():
disconnect(“host_disconnect”, _on_host_disconnect)
multiplayer.multiplayer_peer = null
get_tree().call_deferred(“change_scene_to_file”, “res://Scenes/UI/main_menu.tscn”)
I tried doing it on the server-side at first, which was a mistake, so I thought that I shouldn’t mess with it. I finally tried on client-side and it worked thanks for the help guys you are amazing
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.