Making a multiplayer game with Phaser 3

I’m working on a multiplayer game in Phaser 3 + React for the frontend and TypeScript for the backend. I’m curious about the best practices of making the game server authoritative. Right now I’m using some trigonometry to calculate the hitbox coordinates and checking to see if any player’s sprite has overlapped with those coordinates. I’ve heard of some people using Phaser headless and others using Arcade Physics as a way of making the game server authoritative and using those for collision detection. With my method I’m concerned about figuring out how to check if obstacles are in the way of the hitbox’s path. Is there a recommended way on making a multiplayer game server authoritative with Phaser? I’m assuming there’s a better way of handling the backend compared to what I’m doing right now but I’m not entirely sure.

Every Phaser dev making an online multiplayer game goes through a phase where they dabble with the idea of headless Phaser on the server, then realise after looking into it that that is a silly idea.

A better idea is to run the same code on server and client, but restrict it to vanilla JavaScript without references to Phaser functions or methods. If your game has random elements, generate a seed for an off-the-shelf RNG library ( I use chance.js) on the server and send it to the client so that they run the same operations.

My game is turn-based autochess (plays out automatically) but it sounds like yours includes live user input, which adds complexity, but the above should be the basis of your solution. Good luck.