Release 0.25.0
This version now targets bevy 0.17!
Merge Predicted, Confirmed and Interpolated
This is a big change. In the past you would have 2 separate entities:
- a Confirmed entity that contains the remote state received via replication
- a Predicted entity that lives in the future compared to the remote and contains the predicted state of the entity, or an Interpolated entity that lives in the past and contains the interpolated state (interpolated between 2 consecutive Confirmed states)
This model had a lot of flexibility since the entities were separate, but it also added a lot of extra complexity:
- non predicted components had to be synced from the Confirmed to the Predicted entity
- we had to apply entity-mapping from the Confirmed to the Predicted entity
- sending a message from the client to the server about a Predicted entity was tedious, as you had to map from Predicted entity to Confirmed entity first
In this version I'm opting to greatly simplify the logic by merging all these entities into one.
If an entity is Predicted/Interpolated, then the marker component will be added, no additional entity will be spawned.
For Predicted/Interpolated components, the replication updates are now inserted as Confirmed<C> instead of C. Other components are inserted directly as C.
This also removes the need to specify a PredictionMode or InterpolationMode, which have been removed. InterpolationManager has also been removed.
PreSpawned can now be used outside of Prediction
There are situations where you might want to replicate an entity from the server to client, but instead of spawning a new entity on the client you want to target an existing entity. We already had a solution for this, the PreSpawned component, but it was only compatibly with Predicted entities.
It now works for all replicated entities.
The PrePredicted component is now removed as it was complicated to reason about, and I believe that all use-cases can be filled by the PreSpawned component.
DeltaCompression Changes
- DeltaCompression must be added AFTER prediction/interpolation in the Protocol for it to work properly. This is probably a temporary restriction that will be lifted in the future.
- The
Diffabletrait now hasDeltaas a generic type instead of an associated trait. This enables implementing Diffable for a type with multiple choices ofDelta. This can be useful for example forTransform, which implements bothDiffable<Isometry2d>andDiffable<Isometry3d>
Avian-specific Changes
Lightyear now supports 3 modes to work with Avian:
-
Position: Position is replicated and is used for FrameInterpolation and Correction. In your FixedUdpate systems you must update Position and not Transform. -
PositionButInterpolateTransform: Position is replicated, but Transform is used for FrameInterpolation/Correction (this can be convenient since FrameInterpolation/Correction are mostly visual concerns). In your FixedUdpate systems you must update Position and not Transform. Note that there might still be issues with TransformPropagation to children. -
Transform: Transform is replicated and is used for FrameInterpolation and Correction. In your FixedUdpate systems you can update either Position or Transform.
The LightyearAvianPlugin must now be added manually to your app, it's not added automatically when the avian feature is enabled.
The IslandsPlugin and IslandSleepingPlugin need to be disabled if using input-based replication as they cause issues with rollback.
BevyEnhancedInput
- Rebroadcasting BEI inputs now works correctly in HostServer mode
- The serialization model has been reworked to consume a LOT less bandwidth (up to 6-7X less)
DeterministicPredicted
A new field skip_despawn has been added to DeterministicPredicted.
By default it's false, and any rollback where the entity was spawned after the start of the rollback will cause the entity to be despawned. This is usually what you want if the entity was spawned as part of some input (for example a projectile that is fired when a button is pressed). But in some cases you don't want the entity to be despawned, for example if the entity was replicated by the server as a one-time event. In those cases you can set skip_despawn=True.
Projectiles example
A new example has been added to showcase different ways of handling projectile replication. It is by far the most complex example to date and shows how to handle concepts like:
- entity visibility via rooms
- physics handling with avian
- multiple replication models (deterministic-only, interpolated-only, all-predicted, etc.)
- bevy_enhanced_input with input rebroadcasting for predicting other clients
- lag compensation via the LagCompensationSpatialQuery
What's Changed
- Fix steam callback system by @ironpeak in https://github.com/cBournhonesque/lightyear/pull/1212
- fix(transport): fix rare bug when ack metadata causes a panic on wrapped PacketId by @cBournhonesque in https://github.com/cBournhonesque/lightyear/pull/1214
- feature: adding UI panel with debug information by @cBournhonesque in https://github.com/cBournhonesque/lightyear/pull/1216
- feature: simplify interpolation by @cBournhonesque in https://github.com/cBournhonesque/lightyear/pull/1217
- Projectile example: various fixes + add shooting bullets by @cBournhonesque in https://github.com/cBournhonesque/lightyear/pull/1218
- fix: remove disconnected clients from replication components by @cBournhonesque in https://github.com/cBournhonesque/lightyear/pull/1221
- fix: make bot shoot as well by @cBournhonesque in https://github.com/cBournhonesque/lightyear/pull/1222
- fix: don't import websocket server prelude in wasm by @AdamWhitehurst in https://github.com/cBournhonesque/lightyear/pull/1230
- feature: merge Predicted/Interpolated entities with Confirmed entity by @cBournhonesque in https://github.com/cBournhonesque/lightyear/pull/1229
New Contributors
- @ironpeak made their first contribution in https://github.com/cBournhonesque/lightyear/pull/1212
- @AdamWhitehurst made their first contribution in https://github.com/cBournhonesque/lightyear/pull/1230
Full Changelog: https://github.com/cBournhonesque/lightyear/compare/0.24.0...0.25.0