Multiplayer basic guidelines for a card game

I’m working on my first multiplayer game (via Lan) , it’s a standard card game , right now all the game is based on ""unity UI and drag& drop mechanism only “” … for the last two days i was reading and watching tutorials about multiplayer and networking in unity , but I’m still confused about some basic stuff , so this is actually not a single question .
The only difference between player 1 and 2 is that neither of them can’t see the other hand (the card should be face dawn) , they both share the same deck of cards , is it necessary to make a player prefab and spawn it ? … I already created the draw an throw methods should i change that (split it) to a some thing like a Server draw and Client draw when it’s basically do the same thing ?

Hi @khalidhex

This is difficult and long topic, however, I’ll try to guide you a bit, basically, you have 2 options:

  1. P2P
  2. Authoritative Server

Both of them have pluses and minuses

P2P - where users connect directly to each other and play directly without server in the middle

Pluses:

  • Players play directly and you dont need to worry about hosting server and all problems related to that

Minuses:

  • P2P games more vulnerable to cheating
  • One of the players who randomly will be selected to act as a server will have to allocate extra performance for handling server logic
  • It is much harder to connect 2 players directly because of routers, port forwarding (search for NAT punch-through)

Authoritative Server

Pluses:

  • Easy to control game flow and prevent from cheating
  • Allow easy statistics and analytics gathering
  • Easy to connect 2 players with each other

Minuses:

  • You need to host it
  • You need to solve performance problems as your “the only one” server will have to handle thousands of clients or more

There much more pluses and minuses for both of them, i just highlit main pros and cons


From that, you decide what type you chose and go for implementation

Implementation logic for Authoritative Server:

  • Server holds entire game session details, main deck, and exact cards per player
  • Clients should know only own cards - and see only selected opponent card which he used/revealed right now and all others which were already opened in the past. don’t keep in memory full opponent cards list, only the one which was used right now or already were discovered
  • Result of all players movements and final decision made on the server, and the server just notify players about own final decision.
  • Clients trust to server decision without questioning

Implementation logic for P2P:

  • Each of your players should contain 2 logics: Server and Client
  • One of your player selected to act like a server (randomly or based on hardware or network specs or else…)
  • For player the same logic as per Authoritative Server
  • For another player who selected to act as a Server need to implement server logic and client logic together.

i’m also creating my first multiplayer game in unity is LAST Card game i’m also facing all thses problem please can you help me

Hi @khalidhex,

Do you find a find a way to solve the problem ? I’m also trying create a multiplayer card game but I have the same problem.
Thanks