Godot Version
Godot 4.2.2
Question
I’ve just been getting a weird problem in my game. and it fixes itself completely when the host completely quits the game. The problem is when the host quits the game to the main menu no one else can create a server on the same port, when switching to a different port or the original hoster quits the game fully the problem is fixed so it is definitely a problem with the port remaining active or something?
is there any specific syntax that I am missing that would fix this? or alternatively if someone has experience with GodotSteam maybe you could tell me if this would ever be a problem using steam networking as that is what the release game will be using. Your time is much appreciated
This is the quit code incase that is the problem
func _on_quit_pressed():
var Mission = Global.current_mission
var id := multiplayer.get_unique_id()
if Global.is_multiplayer == true:
if multiplayer.is_server():
disconnect_all(id)
multiplayer.multiplayer_peer.disconnect_peer(multiplayer.get_unique_id())
else:
disconnect_self.rpc(id)
get_tree().change_scene_to_file("res://Scenes/Menu.tscn")
elif Global.is_multiplayer == false:
get_tree().change_scene_to_file("res://Scenes/Menu.tscn")
@rpc("call_local", "any_peer")
func disconnect_self(peer_id : int):
for i in GlobalMissionManager.Players:
if GlobalMissionManager.Players[i].id == peer_id:
GlobalMissionManager.Players.erase(peer_id)
reset_player_list()
await get_tree().create_timer(0.1).timeout
multiplayer.multiplayer_peer.disconnect_peer(peer_id)
@rpc("call_local", "any_peer")
func disconnect_all(host):
for i in GlobalMissionManager.Players:
if i != host:
multiplayer.multiplayer_peer.disconnect_peer(i)