Client disconnected from Server when changing scene

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By deathgm

I’m making a multiplayer game.

When i change current scene to another scene, client disconnected from server.

My scene is quite heavy so it takes a long time to load and disconnects during that time

Does someone have a solution for this?

First clarify a couple things.

  1. Is your connection information tied to the scene you’re changing away from?

  2. Is it the main scene you’re changing?

  3. When doing long tasks its advised to start it on another thread as the main one is mostly used for display related events. That said can the loading of your new scene be done in parts?

Wakatta | 2021-09-01 21:50

I don’t know what to say but I am creating a lobby then when enough players it will start the game and switch from the current scene to the “map” scene

deathgm | 2021-09-02 10:06

My point exactly let’s say you have this setup

class_name Lobby extends Control
var peer =

func ready():
    peer.create_server(SERVER_PORT, MAX_PLAYERS)
    get_tree().network_peer = peer

What do you suppose happens to the peer var once the scene is changed?

It gets freed that’s what

Wakatta | 2021-09-02 10:58