rameshvarun / netplayjs

Make P2P multiplayer browser games, no server hosting or synchronization code required. Powered by rollback netcode + WebRTC.
https://rameshvarun.github.io/netplayjs/
ISC License
486 stars 34 forks source link

Add Delay-based Netcode #27

Open rameshvarun opened 3 years ago

rameshvarun commented 3 years ago

Lockstep netcode allows you to synchronize a deterministic game over the network even if you cannot serialize / restore it. This is used in the physics demo. However lockstep is not really practical, since a stall-free experience requires latency < timestep.

Delay-based netcode adds input delay to allow additional time for inputs to resolve.

I think the best move is to add this as a new class. Trying to implement delay as a parameter to LockstepNetcode could make the lockstep code too complicated.

ryanodd commented 2 years ago

I think input delay would also be useful to apply to rollback netcode, in my opinion about 2 frames of input delay usually makes rollback a better experience. Without a few frames of input delay, player will see more 'warping'.