- Home /
Stop host without kick clients
Please help me with this subject, I really want help, I want that stop hosting without kick any client, by the way, I'm following BRACKIES multiplayer tutorials.
You'll have to make someone else the host/master client.
Answer by MUG806 · Feb 20, 2021 at 01:29 PM
If you stop hosting there is nothing for clients to be connected to. What you are asking for is completely impossible.
Not completely impossible but quite difficult to pull off and requires several steps in order to be even remotely reliable. The overall them is host migration. There are different kinds of host migration depending on what exact situation you want to resolve. You can roughly split the scenarios into active and passive migration. Active host migration means the current host actively wants to give away his host role. Passive host migration is a lot more complex and is about a host that suddenly disappears / looses connection. Passive host migtation has a very low chance to be pulled off successfully. Active migration has a higher change but it's still not guaranteed that it will work.
Active migration essentially has those steps:
Current host picks one of the clients to become the new host.
Once the client has been informed about that decision that client has to start its own server.
The current host connects to the new host to see if the connection can be made. Ideally all other clients should also connect to the new host while still being connected to the old host, just to make sure no-one is left behind.
Once the connections are verified to work (just doing some handshaking) the current host can send the whole gamestate to the new host
Finally after the new host has setup its own environment to be a "clone" of the original one, the old host can officially send out a migration command to all clients. From that point on the connection to the old host can be closed by all clients and everything can continue over the new connection with the new host.
Passive migration has way more potential issues. To support passive migration all clients have to have a complete copy of the game state at all times since each client has to be ready to take over the host role. Ideally each client always runs their own server socket in parallel and all clients are essentially directly connected to all other clients. When the host dies the clients have to negotiate if the current host is dead or not and who's going to be the new host. Supporting passive migration has a lot of issues. First of all the whole gamestate has to be shared with all clients. This is a huge issue for cheating. Likewise because all clients have to know each other player it may be a privacy issue.
Note both types of host migration is not easy and require careful housekeeping of literally everything. UNet had support for host migration. Though the success depends many factors.
Your answer
Follow this Question
Related Questions
Unity networking tutorial? 6 Answers
Multiplayer syncronisation 1 Answer
Using a database for unity multiplayer project 1 Answer
When i connect to my server the host can't move just the client can move. 2 Answers
Client interact with World Objects 0 Answers