Multiplayer Game with Server-Side physics - not getting it working...

hi,
this is my first time testing Phaser. i want to create a real-time multiplayer with server-side physics.
I’ve found this tutorial: Creating A Simple Multiplayer Game In Phaser 3 With An Authoritative Server – Part 1 – Phaser GameDev Tutorials

I’m not able to get my player-models to “bounce” on world collide nor did i get managed the client-side update…

First:
here is a snipped of my “server.js” file, responsible for building up the socket.io and jsdom for server-side phaser:
https://jsfiddle.net/ragesoft/xLa2bcmv/
It creates the virutal webbrowser and loads the game.js and ressources.

Second:
This is the “game.js” file, responsible for all phaser logic on server side:
https://jsfiddle.net/ragesoft/2re13c0b/

Inside the “game.js” i’ve allready made a “fix” for the ‘setCollideWorldBounds’ with some simple “if-statements” :slight_smile: but thats not nice at all… physics should do it for me…
If i comment it out, the hero is moving off-screen

So my question:
What am i missing on server-side to get physics corretly running? Why my hero can move out of the scope of my world boundaries?
The heros collition seems to work correlty.i can push over other heros…

Thx a lot!

1 Like

I’ve found another solution to this problem:
seems as soon as u are using a group and add sprites to it, some properties of the sprite getting replaced by group settings.
So:
if i create a sprit, set it to collide with world and than add it to the group, it will fail.
if i create a sprit, add it to the group and than change the collide it works.

Other option:
Create the group and set the default setting for all group objects:
myGroup.defaults.setCollideWorldBounds = true;

:slight_smile:

1 Like