Overv / WebCraft

Minecraft clone written in Javascript.
zlib License
386 stars 179 forks source link

physics in multiplayer #44

Open mmccall0813 opened 4 years ago

mmccall0813 commented 4 years ago

How would I go about making physics (ex. sand falling) into multiplayer? It works great in singleplayer, and I'm wondering how I could implement this into multiplayer.

MrSonicMaster commented 4 years ago

server tells you "hey, a block is falling" client does its thing like it would in singleplayer, pretty simple concept right?

mmccall0813 commented 3 years ago

server tells you "hey, a block is falling" client does its thing like it would in singleplayer, pretty simple concept right?

not really... it wouldn't make sense to have client-side physics calculation in multiplayer, all sorts of errors would come up from that such as client-server mismatching (a very bad thing!). because of this, you would need to do all of the physics server-side so no mismatching happens!

MrSonicMaster commented 3 years ago

if the physics implementations are identical, it will work just fine (with some extra code to keep them synced in case something does go wrong) - this is a great article describing the concepts: https://www.gabrielgambetta.com/client-side-prediction-server-reconciliation.html