Hi!
I’m thinking about writing a descent clone. That is, you fly around in your futuristic ship in a maze and blast the other players with futuristic weapons. However, when really thinking about networking, I have some problems.
- How smart is the server? Does it handle more than connections, scores and shuffling messages around.
- What is a good solution for determining hits? (bullets can be both lightspeed and “slow” (slow =~ 200 m/s)
Should this be on the client that fired the bullet? (potential cheat problem and it works to good when the network is congested)
Should it be on the server? (the server need to have a complete physical representation of the game, otherwise the safest solution)
Should it be on the client that is hit? (similar problems as when it is on the client that fired the shot).
Should it be a combination? The firing client determines the exact hit (with the 3D geometry) and the server checks that the shot is within bounds.
I am thinking something like this:
- When connected, the server tries to determine the average ping of the client. Then server tells the client the server time. Everybody knows about the server time. Every state update package includes the server time, like: “I am Here at this Time”.
- Every time a client updates its state (not counting simply traveling forward) such as turning ever so slightly, it sends a message to the server to update this. The server makes sure this is reasonably (to prevent cheat) and forwards it to the other clients. Kind of like dead reckoning, but always sending updates with player input.
- All clients simulate physics.
- When a client finds that the new packet from the server mismatches with where it is in the local simulation, it is eased to the new position over a few frames. It can be that a ship collided with something static in the local simulation but the player really avoided the obstacle.