Hi, im making a multiplayer game for me and my friends, and when a player leaves to the lobby, it shows the canvas etc., but when the server host leaves, it just shows a gray screen for everyone else, no buttons, nothing. I thought maybe if there is something like “if !multiplayer.is_connected:” but there isnt nothing like that or im just blind. Im new to making multiplayer games, so please be patient with me ive only been making singleplayer ones so yeah.
Heyo, that’s implementation-dependent. If you’re using the default implementation (SceneMultiplayer), there are signals on the client-side for the server disconnecting, here’s my implementation kind of stripped down for what you wanted:
public partial class GameClient : Node
{
// ...
public SceneMultiplayer SceneMultiplayer => Multiplayer as SceneMultiplayer;
// ...
public override void _Ready()
{
// ...Setup peer, etc...
SceneMultiplayer.ServerDisconnected += OnServerDisconnected;
// ...
}
public override void _ExitTree()
{
// ...
SceneMultiplayer.ServerDisconnected -= OnServerDisconnected;
// ...
}
private void OnServerDisconnected()
{
// Do whatever :D
}
}
This is in C# but obviously the signals and such exist in GDScript too.
There are also signals for peers disconnecting on the server-side if you need it.