Skip to content

Release 0.22.0

Latest
Compare
Choose a tag to compare
@cBournhonesque cBournhonesque released this 20 Jul 02:11
· 16 commits to main since this release

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

New Contributors

Full Changelog: 0.21.0...0.22.0