Search code examples
c#unity-game-engineservercross-platformmatchmaking

Server logic for Unity simple game


I am new to game development, can you please give me an advice on how to implement a server for the game done on Unity for both iOS and Android platforms.

There is a task: an online 1vs1 pin-pong game where you can bet your in-game currency. There are (for example) 3 game modes with a bet of 5, 20 and 100 coins. The player chooses which bet he wants to play and queues, then the second player queues for the same bet and a room is automatically created for them where they play against each other up to 10 points to win. It is desirable to implement the selection of opponents by skill/experience of the game. So the beginners play with beginners, and experienced with experienced (logic on the server). Again, the rooms should be automatically generated. There should be no lobby with a visible list of rooms, only the choice of a bet and the expectation of an opponent. The winner gets the full bet (without any fee). There must be a database to save the results and settings of each player. Authorization through social networks and email. Protection against cheaters is a low priority.

How I planned: All physics and logic takes place on the client side. The server creates rooms for the players that waiting for opponents and provides the exchange of platforms location via UDP, and important messages/events via TCP. There will be no game physics and logic on the server side. This server will be connected to the database to save information, leaderboards and number of collected coins and so on ...

Main tasks: C # server for Unity Own logic on the server Ability to work with the database.

I wanted to use Photon server for these tasks, but I cannot understand if it is possible to bind a database, for example, MySQL, and process minimal logic on the server, is it possible at all? What server besides Photon is suitable for this project?(preferably free). I will be glad to recieve some help and to find the correct way to solve this problem.

Thanks.


Solution

  • For something really simple, I'd recommend using your own implementation of socket.io in your client application (c#) and a really basic nodeJS server using socket.io.

    You have built in rooms, event sending/handling it's pretty handy.

    For unity there is a paid asset (BestHTTP that is really good) and a free one (socket.io for unity or something like that).

    You can then use your node server to connect to your database and send data to unity.

    Hope it helped !