1
\$\begingroup\$

I am using socket.io and HTML 5 canvas to build a MMO game as a practice. I finished the client side first and currently I am working on server side. Apparently the position/physics update is on client side for now. But I am facing the decision of moving the position update logic and physics update to the server or leaving them on the client side. If I put the update on the server side I will pass the mousemove/keystrokes to the server. But if I update positions only on clients side I will pass the positinos/directions/speed to the server. Which approach is better in my case?

\$\endgroup\$
4
  • 1
    \$\begingroup\$ Possible duplicate of Should collision detection be done server-side or cooperatively between client/server? \$\endgroup\$
    – Vaillancourt
    Commented Nov 24, 2016 at 12:52
  • 2
    \$\begingroup\$ Never trust the client. \$\endgroup\$
    – Vaillancourt
    Commented Nov 24, 2016 at 12:52
  • \$\begingroup\$ @AlexandreVaillancourt Thanks the link you posted suggests a mix solution which detects the changes in the client and then verify them on the server. Does that mean sending the actual positions/directions/speeds to the server is OK? Sending these data vs sending mousemove/keystrokes have great impact on the structure of my code so I need to choose carefully. \$\endgroup\$
    – newguy
    Commented Nov 24, 2016 at 13:02
  • 1
    \$\begingroup\$ The theory tells that the client sends the input to the server, then 'presume' what the server will return and show it to the player, and 'correct' what's displayed to the player when the answer from the server comes. It's called client side prediction. Since the server is the authority, it prevents some cheating. Take a look at this Source Multiplayer Networking article for more inspiration. \$\endgroup\$
    – Vaillancourt
    Commented Nov 24, 2016 at 13:08

1 Answer 1

4
\$\begingroup\$

Unless you want players to be able to teleport through walls using their browsers build-in JavaScript debugger, you will have to implement any game mechanics worth manipulating on the server.

This will lead to more noticeable lag, so you might implement it both on the client and the server. That way the client can perform the action locally so the player gets an immediate response to their input, but revert that action when the server says it failed.

\$\endgroup\$
2
  • 1
    \$\begingroup\$ So the game updates codes in client and server are pretty much the same except for reformatting the received data and state interpolation? \$\endgroup\$
    – newguy
    Commented Nov 25, 2016 at 3:37
  • \$\begingroup\$ @newguy Basically yes. \$\endgroup\$
    – Philipp
    Commented Nov 25, 2016 at 8:35

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .