i'm trying to figure how a phisics game like billiard works in server side . I'm asking this cause i know how to achieve this in a client , but if i use a phisics motor i think it could be very heavy for a server when i want to have many people in the server.

When i see this type of games, it use to be really fast , thinking that server is controlling the movements of course . Cause any other way maybe from client you could have been doing cheats.

Then my questions are:

The server sends in this case, all ball movements? Are the server trusting in clients? In this case : How to be sure a phisics motor doesn't have little error. (float decimals differences)

And globaly : How this type of server works?

  • \$\begingroup\$ I don't have a full answer, but I'll say that billiards is a really good game for physics online. That's because only one player at a time is active, and you don't need to worry about multiple players interacting at the same time with physics objects. Also, billiards has a relatively limited number of objects in motion at once, meaning you can probably perform some very efficient calculations for ball collisions that can keep your server CPU load low. \$\endgroup\$ – Tim Holt Apr 23 '12 at 2:39

As with most things in game development, there are a number of ways to tackle this issue. The most common way I have seen is to have the client-side physics be completely "dumb."

The simulation on the client side is merely reacting to data delivered by the server and inputs from the client side are sent to the server, interpreted and distributed to all connected clients as data. You can easily do very basic cheat detection during this "interpretation" step by ensuring that the move the client is attempting to make fits within the rules of your game. For instance, in the context of your billiards game, if the server currently has ball1's position as (x:26, y:50) in the game world and suddenly fields a request to move ball1 from (x:35, y:50), you know something strange is going on. Now "something strange" could be either network latency, dropped packets or player tampering and it's up to you to decide how to determine the cause and handle it.

This article by Gaffer on Games (really great source), can explain in much more detail than I ever could, but these are the essential steps:

  • Player presses a key or invokes an action.
  • Action is sent to the server.
  • Server interprets the action for the player.
    • Server checks if the action is valid.
    • If valid, server applies action to all relevant game objects.
  • Server sends updated data on all affected objects to all connected players.

With this implementation, the drawback is that because real game data is only flowing one way (server to player), and network transmission is never perfect, the client has to do some guesstimating. This is called client-side prediction and is covered in the section of the same title in the article linked above.

Even though you're not working with the UnrealEngine, their Networking Overview article does an excellent job of explaining how their server-client system works and how they tackled certain challenges that exist in managing multiple objects and states over network.

Hope this helps!

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.