Release 0.22.0
Upgraded rollback detection
Previously there was only one way we could rollback: if we received a new state update on the Confirmed entity which did not match the prediction history.
Now we have separate a RollbackMode for state replication and input replication; the possible values are Always
(rollback whenever we get a new state or input), Check
(rollback whenever we get a new state that doesn't match the predicted history, or a new input that doesn't match the input history), Never
.
The Always
mode can be useful to force trigger rollbacks and to check if your game can handle a certain amount of rollbacks.
But the main benefit is that this change allows for deterministic replication; a networking model where only inputs are replicated (instead of state).
Deterministic Replication
Lightyear now supports deterministic replication! In this mode you can choose to replicate only inputs; each client should receive the inputs from all other clients and use that to deterministically simulate the game.
The API is extremely similar to state replication: instead of Predicted
you need to add the DeterministicPredicted
component!
By adjusting the InputDelayConfig
you can decide the level of prediction that is applied:
InputDelayConfig::no_prediction
: there is no prediction so the clients will progress in lockstep. NOTE: there currently is no check that for a given tick we have received all the inputs from all clients!- with input delay: the local client will predict all other clients' actions
A new example has been added that illustrates those 2 modes.
Note that you can also do a mix between state replication and input replication!
Rollback overhaul + bug fixes
The rollback logic has been overhauled, in particular the logic that was handling the smooth correction from the previously predicted value to the new corrected value. Thanks to the help of @maniwani for that!
I've also fixed a big number of subtle bugs related to rollback, timeline syncs and input buffers.
The result is that rollbacks are now MUCH smoother, as you can check yourself by running the deterministic_replication
, avian_physics
or avian_3d_character
examples. This is a huge upgrade that I am extremely happy about.
Support for immutable components / deprecation of RelationshipSync
It is now possible to use immutable components in the protocol; you will have to use add_immutable_prediction
instead of add_prediction
, and they are not compatible with PredictionMode::Full
.
With this change, the RelationshipSync
plugins are not needed anymore.
To replicate Relationships you can just add them directly to your protocol, like so: app.register_component::<R>()
What's Changed
- fix(avian): improve avian plugin system ordering by @cBournhonesque in #1066
- fix(bug): fix important bug on input broadcast by @cBournhonesque in #1067
- Make sure that remote inputs are correct during rollbacks by @cBournhonesque in #1069
- Crossbeam clone by @SueHeir in #1070
- remove direct steamworks dependency by @extrawurst in #1073
- chore(docs): explain handle_predicted_spawn more by @interwhy in #1076
- skip crossbeam links in ServerUdpIO by @SueHeir in #1078
- feat(rollback): add more conditions are rollback checks by @cBournhonesque in #1079
- Fix RemoteTimeline syncing by @Avilad in #1085
- Add deterministic replication example by @cBournhonesque in #1087
- fix(rollback): More rollback fixes for deterministic replication by @cBournhonesque in #1089
- feat(rollback): Add RollbackMode::Check for inputs by @cBournhonesque in #1091
- Remove symlinking in favor of lib paths. by @BigBadE in #1090
- feat(deterministic): Add lightyear_deterministic_replication by @cBournhonesque in #1092
- fix(lockstep): fixes for lockstep by @cBournhonesque in #1099
- chore(docs): improve docs for ShouldRollbackFn by @cBournhonesque in #1104
- chore(inputs): simplify native inputs by @cBournhonesque in #1107
- fix(avian): update avian examples by @cBournhonesque in #1112
- fix(example): fix system ordering in avian 3d example by @cBournhonesque in #1114
- Support immutable components in prediction/interpolation by @cBournhonesque in #1105
New Contributors
- @extrawurst made their first contribution in #1073
- @interwhy made their first contribution in #1076
- @Avilad made their first contribution in #1085
Full Changelog: 0.21.0...0.22.0