I am developing a 2D multiplayer game as follow:

  • semi-authoritative server
  • handle up to 40 players per game.
  • Players and other game objects will interact/collide with each other
  • Physics like bouncing are required

Technologies I am planning to use:

  • Clien: unity3D (easy to develop + cross-platform)
  • Server: node.js + socket.io (easy to deploy and cheap to host)

Considering that most networking solutions for Unity3D are expensive and not suitable for small games/projects and UNET still under development...

By using a different physics engine on the server side like matter.js + node.js:

1- Would it affect the gameplay and the game objects synchronization?
2- Would it be impossible or very hard to provide a smooth physics experience to the player?
3- Is there any other issue I should expected to deal with?
4- Is it a bad idea?

Any peace of information will be well appreciated. tks


When you use two different physics engines, it will be almost impossible that they will always come to the exact same results. Large physics systems can behave quite chaotically (small changes in variables create drastically different outcomes). So considerable desynchronization will become inevitable.

The most obvious solution would be to keep the physics completely under the authority of the server: Nothing moves until the server says it does. But that will affect the game experience negatively because players will notice the lag. So you will have to use the client-sided physics engine to estimate what the server-sided physics-engine will do and then correct any differences as soon as possible.

You could have the server send the physics-state of all game-objects to the client at regular intervals and then have the client correct all physical attributes as soon as they receive them. How well this works will depend on your game (how much physics interaction you have and how chaotic it will be) and how well you can get the two physics engines to behave nearly the same.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.