Phaser 3 Integration - Server and client?
dpastorini last edited by
In reference to the old post, is really a good idea to have all the physics and logic on the server side?
Wouldn't that overhead the server with calculations that should be done on the client?
What's coming to my mind is something like:
A1 - The client A press "left" > which sends a small package to the server with the action (let's say something like "A=L").
A2 - The server does nothing with that but broadcast it to every other client (again "A=L").
A3 - Then client B who receive this will calculate client A result position and update the view accordantly.
Isn't that better than:
B1 - The client A press "left" ("A=L").
B2 - The server calculates the new position and broadcast something like "A=[new-position-data]"
B3 - Then client B updates the view using [new-position-data] instead of calculating the new position for A based on A pressing left.
I'm guessing the problem will be on saving the A "real-position" as the player real state on the server, right? Something like to validate each player position after pressing left?
Could this be like something to avoid possible hacks on the client side?
@halome , do you have a final version of your integration to share? Did you used Phaser 2 or 3?
I'm looking to use Phaser 3 in my game along with Colyseus and MySQL.
No need to say I'm new into game development (I'm just working on my first game), so I have a lot of questions like this :P
Thanks in advance!
lw1990 last edited by lw1990
Client-side logic has the advantage of being low latency, so user experience is better.
But for multiplayer games, this is a major problem - client side logic can be altered so that cheating works.
In 2018, for most browser based games, server-side logic is sent fast enough because of internet speeds to not cause a bad user experience, and has the massive benefit of being safe from cheating. It also prevents clients 'getting out of sync' accidentally even if not an intentional cheat. Finally it helps protect your source code from people who would just clone your client and make their own identical game.
The ideal implementation would be client-side logic which executes first, then server-side logic which executes, and if they mismatch, the game state is updated to the authoritative one dictated by the server. This allows low-latency for the clients and prevents cheating. The problem with this ideal implementation is that it's complicated, and not necessary for most use cases.
dpastorini last edited by
Thanks for the reply @lw1990
I'll look for the solution like it's mentioned in the old post then.