Jump to content

Need some advice. Multiplayer nodeJS box2d and maybe phaser


piranha
 Share

Recommended Posts

I started working on a top down racing game as fun project a while back. I didn't use any game framework. Only node.js, express.js, socket.io and bunch of node modules and webpack. I got a working prototype where I can drive around and get real time sync between players that was good enough for now. The next thing I started on was collision detection. After a while I realised that I need some framework for it rather than create my own thing. After some research I started looking at phaser and finally bought box2d plugin for phaser which included a simple top down racing game as a example. I spent some time on tweaking parameters and got a result I was happy with. So I brought phaser into my project and got problems with pixi.js on the node server because there are no dom elements and pixi seems to be baked into phaser.

After some googling it seems like running phaser on the server is a bad idea, but I only wanted box2d anyway. So I got a box2d version called box2dweb and tried to create the same thing that I had working in phaser + box2d. After getting errors I couldn't figure out it turns out after some googling that there is missing functionality (edgeChains) in box2dweb. So I try all the other implementations of box2d in JS that I can find and all of them reports errors (different errors with each version) and it's code that works fine in the box2dweb version. Sigh.

I can not be the first person wanting to do a real time multiplayer game using node and box2d. Any advice how to move forward?  

Link to comment
Share on other sites

I never used phaser's box2d, but my guess is that `edgeChains` is a part of phaser's code, sort of extension of the pure box2d. For multiplayer you want to be absolutely sure the physics runs the same on both clients and the server, so my recommendation would be to use box2dweb or any other physics engine you want both on the client and the server.

You might also be able to look at phaser's source and see how the `edgeChains` class works and replicate it yourself for the server.

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...