I am developing a two player multiplayer game. Since its only two players, I don't want to keep my connection open if a player disconnects.
Now this works well from the host side, through usage of StopHost()
. If the player who hosts disconnects, it disconnects both the players from the game.
But using StopHost()
in the client(Player B) side does not remove the host player(Player A). In other words, the client is out of the game, but the host is still in the game.
So, what I want is if one player(host or the client whoever it is) disconnects, I want both of them to be disconnected.
So, how can I do it? Please help me with this. I have almost lost hope with UNET. Thanks
EDIT:
My setup is like this, my LobbyManager comprises of UI elements like "TitlePanel", "MainPanel", etc. The Disconnect button is part of the title panel and gets enabled on press of Esc key. The button is linked to a script attached to the "TitlePanel". This script uses a MonoBehaviour
which I changed to NetworkBehaviour
in order to use [Command]
. But it doesn't work as my "Title Panel" does not have a NetworkIdentity
. Adding one creates even more problems
So, I thought if there was a way to send mesages from client to server without NetworkBehaviour, then maybe I could send a flag there to the server.
So is it possible?