I am making cards multiplayer game using Unity networking.
I am using both matchmaking and LAN networking.
Now my question is : what is best way to achieve a connection “resilency”, where a player may disconnect completely for a while, but comes back before “timeout”, and continues game play where he/she may have left ?
I searched my self the documentation but couldn’t found solution exatcly for this.
If anyone aware of please let me know
Thank you in advance.
It really depends on the structure of your game. For mine, the player state is always being backed up to a database server, and restored whenever they log in later. So it doesn’t matter if they log off for 40 seconds, 2 minutes, 2 hours, or 2 weeks, and it doesn’t matter if the server is taken down in the mean time.
If you’re not storing player data on a central server, and are client authoritative, you could store everything about the player locally on the client (in your own data file or in playerprefs for example), and then when your client reconnects to the host you push all the data about the player to the server via commands or messages, which then push to everyone else via SyncVar, ClientRPC, messages, etc.
1 Like
You may want to look at implementing it with a turn based networking solution, Photon and GameSparks can both handle the type of scenario you described.
Thank you [Joe-Censored]( How to re-connect player with previous state of game if player disconnect for while? members/joe-censored.234917/) and [Munchy2007]( How to re-connect player with previous state of game if player disconnect for while? members/munchy2007.312346/) .
I think I will stick with unit networking for now but will have to make a robust data storing and retrieving code myself for this. Thank again , your opinions create confidence as I had almost both the opinion but wasn’t sure about any before you answers.