I'm trying to build an online game server for my Tank game 2D (Unity). In my game there will be 2-4 players control their tanks and fight each other.
I've tried to use Unity networking, it was not really suitable for my game because we have to choose 1 of the players in the room to become the "server", which is not really flexible for my future development (e.g. when the "server" quit, I have to do a lot of work to remain connections between the other players).
Then I've tried to build my own server with Nodejs là socket.io for server-client communication. It's very simple: receives data from one and broadcasts them to the others. It seems to work fine until the physics part comes in: the server must trust the clients when they say there's something being hit or explode, then broadcasts it to the other clients. Not to mention the cheated clients, with the network latency, the physics simulation of the clients will vary. For example, a tank might be hit on this client but it should be covered behind the wall on the other one and stay alive, but the tank behind him catches the bullet and explodes, because of the latency. In these cases the server doesn't know which one to listen to.
Update
- As @Catwood mentioned below, Photon PUN is another option for me. I had followed one of their tutorials before. Photon doesn't need a player to be the "server" like Unity networking. But how do I implement my game logic on the server? (for authoritative server purpose)
- Apparently Smartfoxserver is another good (and pricey) option. I haven't taken a deeper look at their API document. I'm don't know if I could implement my gaming logic and rules on this (their tutorial skip this part for the sake of simplicity).
In conclusion, I need a suggestion for my game server:
- Is an authoritative server
- Can handle game rules and decide what will happen (maybe should have its own physics engine)
- Works well with Unity2D
- Javascript, C#, Java are preferred!
Am I going the right direction, because seems like some game server services (such as Photon, Unity networking) just don't care about how to implement game logic on the server. And does it make them not an authoritative server?
I am very new to this field, anything will be appreciated!