Lockstep game (only confirmed entities) #779
-
Hi, I have been playing a bit with Lightyear recently and love it! I currently use the default setup showed in examples with predicted entities for current player controlled entities and interpolated ones for the rest. Works great overall, but desync/rollback can quickly become an issue when predicted entities have to interact with interpolated ones (collisions detection...), may be doable properly but need a lot of works. I was wondering, what would be the correct way to do a lockstep game (no prediction nor interpolation, just send inputs to the server, and react to server update for the render) ? As you have to opt in either predicted or interpolated when registering component for replication (you cannot just say, "replicate/full /server to client" afaik) I was thinking of registering all my component with "interpolate/full/server to client" and then only work with the confirmed entities for the render (and actually ignore the Interpolated ones..) |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
Hi, great to hear that you like it :)
You can definitely register a component without prediction/interpolation enabled! See here in the tests: https://github.com/cBournhonesque/lightyear/blob/main/lightyear/src/tests/protocol.rs#L246
Indeed collision detections between predicted and interpolated entities is painful! There are several options: Lockstep games are a bit different, the idea is that the game is fully deterministic and only the inputs are replicated. (i.e. the server just replicates other clients' inputs to all clients). When all clients have received all inputs for a given tick, the game progresses. If an input is missing, the game is stalled. |
Beta Was this translation helpful? Give feedback.
-
Thanks for this great answer! |
Beta Was this translation helpful? Give feedback.
Hi, great to hear that you like it :)
You can definitely register a component without prediction/interpolation enabled! See here in the tests: https://github.com/cBournhonesque/lightyear/blob/main/lightyear/src/tests/protocol.rs#L246
Prediction/Interpolation is totally optional. However you often want to do interpolation otherwise the …