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,
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
Answer by Briksins · May 07, 2016 at 12:05 PM
Hi @khalidhex
This is difficult and long topic, however, I'll try to guide you a bit, basically, you have 2 options:
P2P
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.
Thanks for the tips :) .. i will go with p2p because it's just a Lan game no need to dedicated server , I saw that unity have a build in " network manger" with a simple interface that handle the Lan connections , but i have struggles with it :( i think it's directed to 3d games like fps ,cars and that type of games where you have the player control only his character and the rest is just an environment objects , plus i cant find a tutorial that focused on 2d games .
Answer by Goku007 · Nov 25, 2016 at 08:09 AM
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
Your answer
Follow this Question
Related Questions
UNet - sync child transform scale 1 Answer
Photon Voice chat and Speech to text plugin not working together 0 Answers
TrailRender not showing in all clients using Mirror networking 1 Answer
How to sync RPC function Photon Network? 1 Answer
Unity 5.2 - How can I keep other players from using a menu? 0 Answers