Releases: cBournhonesque/lightyear
Release 0.22.0
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
Release 0.21.0
Lightyear 0.21.0
Multiple crates
This is a massive release that is basically a full rewrite of the crate. In particular, the crate has been split into multiple subcrates, for the following reasons:
- faster compile times
- more modularity by splitting up small pieces into different crates
- encourages a better separation of concerns
This was definitely challenging but I think it's for the better.
Similarly to bevy, you will have lightyear_*
subcrates and a main lightyear
crate which imports every subcrate.
It is possible to use the subcrates directly if you want, as the main crate just imports the relevant plugins from the subcrates.
From Resources to Entities
Instead of managing the networking behaviour via a set of Resources (ClientConfig, ClientConnectionManager, etc.), we now switch to a model where you have one entity per network connection between the local peer and the remote peer. (this approach was pioneered by
aeronet)
-
at the transport layer (how to send/remove bytes):
- you can add one of the IO components (UdpIO, WebTransportIO, etc.) to specify how you will send or receive bytes from the remote peer
- the IO-agnostic
Link
component is used to abstract away from the actual io - you can access metadata about the io link using the
LocalAddr
andPeerAddr
components - the state of the link can be accessed via various marker components (
Linked
,Unlinked
) - the
Transport
component can be added to specify various channels that provide different reliability and ordering guarantees - the
MessageSender<M>
andMessageReceiver<M>
components can be added to add the ability to send and receive structs instead of raw bytes. TheMessageManager
is responsible for handling the serialization and the entity mapping
-
at the connection layer (how to establish a persistent connection on top of the raw io):
- you can add the
Client
orServer
component to specify the role of the entity. In particular, theServer
component will listen for incoming connections and spawn newClientOf
entities for each connected client - the state of the connection can be accessed via various marker components (
Connected
,Disconnected
,Started
,Stopped
) - the
NetcodeClient
orNetcodeServer
components can be added to use netcode as the layer providing authentication + persistent IDs on top of the raw IO
- you can add the
-
at the syncing layer (how to make sure that the local and remote peers are in sync)
- there is now a new
Timeline
component that is used to represent the various networking timelines:- the
LocalTimeline
simply increments the tick whenever the FixedUpdate schedule runs - the
RemoteTimeline
is the local peer's best estimate of the remote peer's timeline; computed from the received packets. This is used to make sure that all the timelines remain in sync with the remote peer - the
InterpolationTimeline
is in the past compared to the Remote, and is used to define how to interpolate between the received remote packets - the
InputTimeline
is in the future to the Remote, and is used to define when ticks should be buffered
- the
- there is now a new
-
at the input layer (how do the clients send inputs to the server)
- the ActionState component defines the current state of the inputs at the current tick. It is guaranteed to be the same between client and server for a given tick
- the InputBuffer component can be used to access the received inputs that were locally buffered
- lightyear now has a shared generic inputs plugin that makes sure input-handling is correct with rollback, input_delay, rebroadcasting to other clients, etc. There are 3 implementations: native, leafwing, and bevy-enhanced-input
-
at the replication layer (how to replicate the state of the World to the remote)
- you can add the
ReplicationSender
andReplicationReceiver
components to specify if you want the peer to be part of replication - the
PredictionManager
andInterpolationManager
mark a link entity as having prediction/interpolation enabled
- you can add the
The bevy ECS provides a lot of flexibility: you can add or remove these components from a subset of the peers to change their networking configuration. Usually if you make changes, they will be applied on the next connection attempt.
This change was mostly made possibly with the recent ECS innovations: observers and relationships.
Moving away from Client-Server
Lightyear was strongly tied to the concepts of client and server. You had to use some specialized client or server resources (ClientManager and ServerManager) and those would have very similar code that varied in subtle ways. For example the replication code was essentially duplicated between them, apart from some server-specific code.
With the new component-based approach, the code has become fairly agnostic to the roles of client and servers.
For example there is now a unique replication system that works on any entity that has a ReplicationSender
component, so each local peer can replicate to a remote peer in the exact same way!
I think this is super exciting as this opens the door to handling P2P topology with code that is very similar to client-server topologies!
Total parity?
This refactor of the crate doesn't achieve total parity with the previous version. Some of the functionality that hasn't been ported is:
- Resource replication: I believe bevy is moving towards resource-as-entities, where resources are simply components stored on an entity. I will just be waiting for this to be merged before re-adding resource replication
- input broadcasting: we previously had convenience functions so that a client could send a message to another client (the message would be sent to the server, who would broadcast it to the correct client). This hasn't been re-added yet
- authority: the handling of authority is still somewhat in flux, I have made steps towards it but it hasn't been properly tested, and the
distributed_authority
example is still outdated.
Extras
-
Instead of maintaining my own steam, webtransport, websocket io layers, I now defer to the excellent aeronet crate!
-
Special thanks to @hukasu for helping me improve the compile time of lightyear!
Next steps
With the increased flexibility and modularity, I would like to tackle:
- handling networking modes where only inputs are replicated, such as deterministic lockstep! I believe this should now be very much within reach, as it mostly involves adding a
LockstepTimeline
to define how the local and remote peers stay in sync - handling P2P topologies
What's Changed
- Bevy main refactor by @cBournhonesque in #989
- Update criterion requirement from 0.5 to 0.6 by @dependabot in #1013
- Fixed Client and server Working in Launcher Example by @JosephLassuy in #1014
- Allow replicating immutable components by @cBournhonesque in #1015
- Release 0.21 rc1 by @cBournhonesque in #1017
- Separate Connected from LocalId/RemoteId by @cBournhonesque in #1018
- Add steam using aeronet by @cBournhonesque in #1019
- Add rollback tolerance to avian examples by @cBournhonesque in #1020
- Fix lobby example (without HostServer) and add protocolhash by @cBournhonesque in #1021
- fix(prediction): add history-buffer for pre-existing components when … by @cBournhonesque in #1022
- Add HostServer by @cBournhonesque in #1023
- chore(example): enable host-client mode on simple box by @cBournhonesque in #1024
- chore(replication): add simple test to check that replicate can be re… by @cBournhonesque in #1026
- fix(host-server): fix overlapping ui nodes breaking disconnect button by @komodo472 in #1030
- fix(host): fix host-server disconnect by @komodo472 in #1031
- chore(host-server): enable host-server for all examples by @cBournhonesque in #1029
- Add #[reflect(MapEntities)] to RelationshipSync by @BigBadE in #1033
- Adds #[reflect(Component)] to Replicate. by @BigBadE in #1038
- feat(BEI): support BEI inputs by @cBournhonesque in #1039
- bug(inputs): fix inputs by @cBournhonesque in #1040
- Make workspace crates depend on individual bevy crates by @hukasu in #1043
- fix(bug): fix bug on fps example with missing PlayerMarker component by @cBournhonesque in #1047
- Updates notes for SinceLastSend and DeltaCompression by @cBournhonesque in #1048
- Alternative replication system + fix delta-compression by @cBournhonesque in #1049
- chore(tests): add tests for delta-compression by @cBournhonesque in #1051
- chore(docs) by @cBournhonesque in https://githu...
0.20.2
- Upgrade avian to 0.3
- Fix wasm support
What's Changed
- Fix inserting ChildOfSync in host-server mode by @cBournhonesque in #1004
- Make Relationship plugins public by @cBournhonesque in #1006
- make AppTriggerExt pub by @cBournhonesque in #1007
- Fix wasm for 0.20.0 by @cBournhonesque in #1003
- Fix examples and upgrade avian by @cBournhonesque in #1008
- upgrade to 0.20.2 by @cBournhonesque in #1009
Full Changelog: 0.20.1...0.20.2
Release 0.20.1
- Upgrade
bevy-metrics-dashboard
to 0.7.0 - Includes an important replication fix
What's Changed
- Cb/0.20 by @cBournhonesque in #999
- Fix replication when server_send_interval > 0 by @cBournhonesque in #1001
- upgrade to 0.20.1 by @cBournhonesque in #1002
Full Changelog: 0.20.0...0.20.1
Release 0.20.0
0.20.0
Replication using required components
The Replicate
bundles will be deprecated in the next version. Instead you can add the ReplicateToServer
and ReplicateToClient
which will insert any other required replication components (ReplicationGroup
, Replicating
, etc.) on the entity.
Batch replication support
Replicated components are now inserted on the replicated entity all at once; this guarantees that observers that rely on the presence of multiple of these components work correctly.
The same guarantee is also applied to components that are inserted on the Predicted or Interpolated entity, so observers like:
fn observer(
trigger: Trigger<OnAdd, Player>,
query: Query<&Color, With<Predicted>>
)
will work correctly because the components Player
and Color
are inserted at the same time on the replicated entity.
No std support
Following bevy's lead, lightyear now compiles without std! Note that all available transports (udp, webtransport, etc.) still require std as of now.
Simplified hierarchy replication
Hierarchy replication has been improved. The ReplicateHierarchy
has been removed and replaced by the ReplicateLike
component. You can insert ReplicateLike
on any entity to specify that it should be replicated using the same settings as another entity. All the replication settings from the 'parent' entity will be conserved, including network visibility, disabled components, replication frequency, etc.
ReplicateLike
will now be inserted by default on any child of a replicated entity. This can be prevented by inserting DisableReplicateHierarchy
on the children entities.
Relationship replication
You can add the RelationshipSync<R>
component on an entity to replicate the relationship R
component.
What's Changed
- Remove replicated components in batch by @cBournhonesque in #858
- Update hierarchy replication by @cBournhonesque in #878
- Add RequiredComponents for replication components by @cBournhonesque in #887
- Clean up prediction_despawn using Disabled Marker by @cBournhonesque in #889
- Replace
ReplicateOnce<C>
withReplicateOnce
by @cBournhonesque in #892 - Network triggers with targets by @cBournhonesque in #895
- Refactor rollback into its own Plugin by @cBournhonesque in #898
- Optimize replication systems by @cBournhonesque in #899
- Cache prediction archetypes by @cBournhonesque in #900
- switch to dedicated component PredictionDisable by @cBournhonesque in #901
- Fixes for bevy-main wrt latest bevy by @alexgershberg in #945
- Add more error-handling to systems by @cBournhonesque in #974
- Make lightyear compatible with no_std by @cBournhonesque in #978
- Upgrade to 2024 edition by @cBournhonesque in #979
- Add hidden lines to setup.md as well as a heads-up by @SadraMoh in #991
- cb/0.20 - fix button clicks, and tweaks for common client renderer by @RJ in #994
New Contributors
- @alexgershberg made their first contribution in #945
- @SadraMoh made their first contribution in #991
Full Changelog: v0.19.1...0.20.0
Release 0.19.0
0.19.0
Visualizer
The visualizer
features uses the excellent bevy_metrics_dashboard to display graphs for every metrics registered in lightyear. There are metrics related to rollbacks, replication, messages, latency, etc. which can be used to more easily inspect what lightyear is doing.

Lag Compensation
Lag compensation is the notion of the server 'rewinding time' to process certain user actions like bullets fired, so that client actions in the predictive timeline can impact replicated entities in the interpolated timeline. This is usually used in FPS games.
The fps
example (previously bullet_prespawn
) showcases how to enable lag compensation for hit detection.
Screen.Recording.2025-01-27.at.5.49.39.PM.mov
In this example, the red player and the blue enemy are predicted, and the green enemy is interpolated.
Bullets are pre-spawned on the client directly in the predicted timeline so they can interact normally with the blue predicted enemy.
To handle collisions with the green enemy we have to use the new LagCompensationPlugin. You can see that the server maintains a history (white bounding box) of the past positions of the green enemy to perform lag compensation (rewind time when computing the collision).
Bug fixes
- Variable input delay had been added but didn't work correctly in some situations. This should now be fixed.
- DeltaCompression, where replication updates are sent as a diff from a previous update, should now work in all situations
- Fixed a lot of cases that were causing extra rollbacks, especially related to PrePrediction and PreSpawning
- Fixed bugs related to transferring authority between client and server (in particular using prediction/interpolation in combination with authority transfer)
- Fixed some edge cases related to visibility management via the Room api
- Fixed issues related to hierarchy, in particular the Confirmed hierarchy is now correctly synced to the Predicted/Interpolated entities
What's Changed
- Fix input delay configuration by @cBournhonesque in #736
- update bevy gap version by @cBournhonesque in #738
- Fix delta-compression by storing ack_tick for each (entity, component) by @cBournhonesque in #741
- add delta compression example by @cBournhonesque in #742
- Simplify examples by removing settings file by @cBournhonesque in #744
- Fix track_change_detection by @cBournhonesque in #746
- Fix example prediction settings by @cBournhonesque in #747
- Remove DisabledComponent in favor of DisabledComponents by @cBournhonesque in #748
- Simplify wasm certificate for examples by @cBournhonesque in #749
- Add event replication by @cBournhonesque in #754
- Re-add serde to examples by @cBournhonesque in #755
- fix auth example by @cBournhonesque in #756
- add unit test for despawning an entity after authority transfer by @cBournhonesque in #757
- Fix prediction/interpolation interaction with authority transfer by @cBournhonesque in #759
- fix pre-prediction by @cBournhonesque in #761
- Make sure ChannelDirection is respected by @cBournhonesque in #764
- Improvements to room logic by @cBournhonesque in #766
- Add interest management unit test by @cBournhonesque in #767
- Add unit test for entity-despawns with interest-management by @cBournhonesque in #768
- Improve the server stop logic by @cBournhonesque in #769
- Fix replicate propagation through hierarchy by @cBournhonesque in #771
- Update Docs, closes #386 by @Jieiku in #770
- Make sure that hierarchy is propagated correctly to Predicted/Interpolated entities by @cBournhonesque in #772
- add unit test for adding a child to ReplicateHierarchy.recursive=true by @cBournhonesque in #773
- add benchmark to measure compilation times by @cBournhonesque in #774
- Type erase the receive-message and receive-event systems by @cBournhonesque in #775
- Improve flow to disconnect client by @cBournhonesque in #778
- fix: register prespawned entity in predicted_entity_map during server… by @OlivierCoue in #776
- Use ComponentHooks to maintain the prediction/confirmed map in sync by @cBournhonesque in #780
- update entity map to return Entity::PLACEHOLDER if the mapping fails by @cBournhonesque in #781
- Fix hierarchy-related system ambiguity by @cBournhonesque in #783
- Avoid entity-mapping error log on preprediction by @cBournhonesque in #787
- Fix rollback for pre-predicted entities by @cBournhonesque in #788
- Add method to get client_addr from client_id by @cBournhonesque in #794
- add missing dependencies, add avian3d simple gamepad support by @Jieiku in #792
- Add system order for avian by @cBournhonesque in #796
- Update HistoryBuffers during client TickEvents by @cBournhonesque in #798
- Rollback improvements by @cBournhonesque in #799
- Add metrics visualizer by @cBournhonesque in #802
- Fix lints by @cBournhonesque in #803
- Fix ServerConnection::client_addr by @cBournhonesque in #804
- Refactor examples to build a single binary by @cBournhonesque in #805
- Update metrics-util requirement from 0.18 to 0.19 by @dependabot in #807
- Fix duplicate entities in PrePrediction by @cBournhonesque in #806
- Spaceships predicted despawn behaviour by @cBournhonesque in #808
- Add metrics for rollback by @cBournhonesque in #810
- add unit test for prespawn despawn by @cBournhonesque in #811
- add unit tests for predicted despawn by @cBournhonesque in #812
- Add non-networked component to despawned predicted entity test by @cBournhonesque in #813
- Create FUNDING.yml by @cBournhonesque in #814
- Fix extra rollbacks on pre-spawned entities by @cBournhonesque in #815
- Fix despawn for pre-spawned entities by @cBournhonesque in #819
- Fix leafwing ActionState staying stuck in JustPressed or JustReleased by @cBournhonesque in #820
- Fix hashing in bullet-prespawn example by @cBournhonesque in #821
- Add alias for Replicate by @cBournhonesque in #822
- add metrics for inputs by @cBournhonesque in #823
- Allow not replicating hierarchy by @cBournhonesque in #824
- Improve visual interpolation for examples by @cBournhonesque in #825
- Move UpdateVisualInterpolation to FixedLast by @cBournhonesque in #826
- Make history buffer pub by @cBournhonesque in #831
- add intoiterator for historybuffer by @cBournhonesque in #832
- Update metrics-tracing-context requirement from 0.17 to 0.18 by @dependabot in #833
- Use a varint to serialize the fragment id and num_fragments for fragment messages by @cBournhonesque in #838
- Fix simple setup example by @cBournhonesque in #843
- Separate new() and new_with_app_id() by @NathanTaylorHunt in #841
- Emit disconnect event...
Release 0.18.0
Release 0.18.0
- Upgrades lightyear to be compatible with the latest versions of bevy, leafwing-input-manager, and edgegap
- Provide support to rollback Resources thanks to @nick-e!
- Various bug fixes
- Paves the way to a deeper integration with @RJ 's bevygap, which is a framework to easily deploy Bevy apps on Edgegap, a multiplayer game server hosting service. In particular @RJ is hosting some of the lightyear examples on https://rj.github.io/lightyear!
What's Changed
- Make the RemoteEntityMap public by @cBournhonesque in #601
- Spaceships example: fix Visual Interpolation bits by @RJ in #599
- Order lightyear plugins w.r.t avian plugins by @cBournhonesque in #602
- Send events as server::events::InputEvent instead of client::events:InputEvent in send_input_directly_to_client_events when using HostServer by @nazgul72 in #606
- Remove unneeded import by @FastestMolasses in #607
- Fix listen-server commands in examples by @qtfkwk in #609
- Fix certificate generate commands in examples by @qtfkwk in #608
- Use the parent's ReplicationGroup when propagating it to the children by @cBournhonesque in #612
- Fix panic when sending too many messages in one packet by @cBournhonesque in #615
- Create server-authoritative 3D physics example by @nick-e in #617
- Support rolling back resources by @nick-e in #622
- Spaceships example: change Without to With in Visual Interp setup by @RJ in #624
- Rollback time resource during rollback by @nick-e in #623
- Add book section describing component prediction criteria by @nick-e in #626
- add unit tests for map-entities related to PreSpawned and Prediction by @cBournhonesque in #632
- Add missing
reflect(Component)
s by @philpax in #636 - Slight adjustments to lobby example. Removing redundancies. First pr by @Sirmadeira in #634
- Separate
Replicated
fromInitialReplicated
by @cBournhonesque in #638 - docs: update resource replication example by @philpax in #640
- docs: basic book contribution info by @philpax in #641
- Update xwt-web-sys requirement from 0.12 to 0.13 by @dependabot in #646
- Update egui_extras requirement from 0.28 to 0.29 by @dependabot in #652
- Simplify wrapping_diff code by @ambiso in #653
- Expose and document
SerializeFns
by @philpax in #654 - Fix 639 by @cBournhonesque in #642
- Update bevy-inspector-egui requirement from 0.25 to 0.26 by @dependabot in #650
- fix: expose ReplicateToServer by @philpax in #657
- Support LWIM 15.1 triple axis input by @msvbg in #661
- Require UserAction bound for InputPlugin by @Aceeri in #665
- Avoid panic when getting EntityCommands in hierarchy by @msvbg in #666
- Disable default leafwing features by @vladbat00 in #670
- Fix compiling in wasm by @vladbat00 in #671
- Fixes #644 by @cBournhonesque in #656
- Update metrics requirement from 0.23 to 0.24 by @dependabot in #675
- Update metrics-tracing-context requirement from 0.15 to 0.17 by @dependabot in #674
- Update governor requirement from 0.6.0 to 0.7.0 by @dependabot in #682
- Adjusting simple box to have map by @Sirmadeira in #678
- Bump codecov/codecov-action from 4 to 5 by @dependabot in #696
- Ignore leafwing test by @nick-e in #695
- Fix tarpaulin compile error by @nick-e in #694
- Fix clippy lint error by @nick-e in #693
- Fixed example floor not being rendered by @sQu1rr in #689
- Update pprof requirement from 0.13.0 to 0.14.0 by @dependabot in #688
- fix: Remove
ring
to fix wasm32 web builds by @cdata in #687 - Update bevy-inspector-egui requirement from 0.26 to 0.27 by @dependabot in #680
- Update metrics-util requirement from 0.15 to 0.18 by @dependabot in #672
- Map entities when rollbacking predicted component by @nick-e in #647
- fix logspam when client disconnects by @cBournhonesque in #698
- Fix pre-prediction example by @cBournhonesque in #703
- fix client replication example by @cBournhonesque in #705
- Update thiserror requirement from 1.0.50 to 2.0.3 by @dependabot in #709
- Update hashbrown requirement from 0.14 to 0.15 by @dependabot in #708
- Update wtransport requirement from =0.1.14 to =0.5.0 by @dependabot in #706
- Compilation fixes by @RJ in #711
- Use a hook on PreSpawnedPlayerObject component to compute missing hashes by @RJ in #710
- Fix pre predicted replication by @cBournhonesque in #713
- package update by @cBournhonesque in #714
- Handle host-server disconnects correctly by @cBournhonesque in #722
- Fix duplicate despawn by @cBournhonesque in #724
- Make states enum reflective for pretty eguis by @Sirmadeira in #723
- upgrade dependencies by @cBournhonesque in #726
- Cargo refactor & examples work by @RJ in #732
- Upgrade to bevy 0.15 by @cBournhonesque in #700
New Contributors
- @FastestMolasses made their first contribution in #607
- @qtfkwk made their first contribution in #609
- @nick-e made their first contribution in #617
- @philpax made their first contribution in #636
- @Sirmadeira made their first contribution in #634
- @ambiso made their first contribution in #653
- @Aceeri made their first contribution in #665
- @vladbat00 made their first contribution in #670
- @sQu1rr made their first contribution in #689
- @cdata made their first contribution in #687
Full Changelog: 0.17.0...0.18.0
Release 0.17.0
Release 0.17.0
Upgrade to leafwing 0.15
Leafwing's newest version brings some improvements to the API, but also fixes an important bug where you couldn't use JustPressed
and JustReleased
in the FixedUpdate
schedule. That was problematic since networking usually requires inputs to be handled in the FixedUpdate
schedule. With this fix it is now much easier to use leafwing-inputs with lightyear.
Added rollback for non-networked components
Previously, only components that were registered in the ComponentRegistry
(meaning that they can be networked) could be affected by rollback. However there's plenty of cases where you might want to rollback non-networked client components: for example rolling back animations or sounds. You can now call app.add_rollback::<C>()
to enable rollback for a non-networked component.
Seamless entity mapping
Previously, entity-mapping was only done on the receiver. (i.e. server spawns E1, sends it to the client who spawns E2 and maintains a mapping from E1 to E2). The mapping wasn't applied when sending messages/updates, which meant that the client had to map the entity manually from E2 to E1 if they wanted to send a message about E2. Entity mapping is now correctly applied in all directions.
Introducing authority transfer
Lightyear
now has the concept of Authority
: which peer (client or server) is simulating the entity and sending replication updates for it? Only one peer can have authority over an entity at any given time.
The server can freely transfer authority over an entity to other peers with the EntityCommands::transfer_authority(new_owner)
command.
The Replicate
bundles automatically provide you with authority over the entity; make sure to remember to update them if you're just adding Replicate
on the server to re-broadcast a client-authoritative entity to other clients.
You can find an example with authority transfer here.
Important fixes
- Guarantee that inputs get synced correctly even in low bandwidth situations. PR
What's Changed
- set the channel priority to INF for ping/pong/inputs by @cBournhonesque in #566
- add MTU config for QUIC by @cBournhonesque in #567
- make InputBuffer::pop public by @RJ in #570
- Update book visual interp page with fixed physics example by @RJ in #571
- Add avian3d utilities by @cBournhonesque in #572
- Upgrade to leafwing 0.15 by @cBournhonesque in #575
- Use
Commands
instead ofWorld
to apply replication updates by @cBournhonesque in #581 - Fixed Local client not sending Connect event in HostServer Mode + Added Test by @zwazel in #578
- Add rollback for non-networked components by @cBournhonesque in #583
- add unit test server send message in host-server mode by @cBournhonesque in #588
- Dependency upgrade (wtransport, xwt, mock_instant) by @cBournhonesque in #589
- Allow seamless entity mapping by @cBournhonesque in #591
- Fix resource replication in host-server mode by @cBournhonesque in #592
- Add authority handling natively by @cBournhonesque in #594
- Excessive iteration over query in simple_box example by @nazgul72 in #596
- Add an example for authority transfer by @cBournhonesque in #597
- Fix Pre-Prediction by @cBournhonesque in #598
- Release 0.17 by @cBournhonesque in #600
New Contributors
Full Changelog: 0.16.4...0.17.0
0.16.4
What's Changed
- Add HostServer test harness by @cBournhonesque in #537
- Let the local-client in host-server mode send a message to the Server by @cBournhonesque in #538
- In host-server mode, send messages from server to the local client by @cBournhonesque in #542
- Emit ConnectEvent correctly on the server in HostServer mode by @cBournhonesque in #543
- Extend prelude with aliases for conflicting items by @cBournhonesque in #544
- propagate replicate for children after the entity is spawned by @cBournhonesque in #548
- fix observer panicking with resource missing by @cBournhonesque in #549
- Add helper functions to map from local world to remote world by @cBournhonesque in #554
- Add linear interpolation for Quat by @cBournhonesque in #555
- Cb/add quat lerp by @cBournhonesque in #556
- Make Lifetime pub by @cBournhonesque in #557
- add option to trigger change detection in visual interpolation by @cBournhonesque in #558
- VisualInterpolation: add option to trigger change detection by @cBournhonesque in #559
- fixes for bevy 0.14.1 by @cBournhonesque in #561
Full Changelog: 0.16.3...0.16.4
Release 0.16.0
Release 0.16.0
Added
Support for Steam P2P
Thanks to a PR from @msvbg , it is now possible to connect to a client acting as host-server by using Steam P2P sockets
The network_send_interval
is now configurable with more precision
Previously you only had access to 2 settings:
- client_send_interval
- server_send_interval
which would control how often the client or the server sent packets to the remote.
Now the send_interval
is configurable:
- per ReplicationGroup (if you want to update an entity less frequently)
- per Channel
This gives you more flexibility to control how often you want to send messages/packets.
For example, you can send replication updates every 100ms, but send client inputs every frame if available. (this setup is particularly useful if you want to predict other player's inputs, a la RocketLeague)
@RJ added an example with remote player prediction
Added better support for handling remote player inputs. Now inputs from other players can easily be forwarded to a given player so that they can run client-prediction on all entities (the local player entity and the remote player entities)
@RJ created an awesome example spaceships
showcasing how to achieve something like this.
It uses input delay, remote player prediction, physics via xpbd, etc.
Updated the InputDelay/Prediction settings [EXPERIMENTAL]
Previously you could only set a fixed amount of input delay (for example 3 ticks).
Now the input delay depends on your network conditions: the settings are identical to what is described here.
Note that this feature is still being tested and might not work if the network conditions are varying.
Miscellaneous
- Some common bevy
RunConditions
are now provided, such asis_started
,is_disconnected
,is_host_server
, etc. - The serialization logic now uses
bincode
instead ofbitcode
. You can provide your own serialization function instead of bincode. - lightyear doesn't use
anyhow
anymore, instead functions now return typed errors such asReplicationError
,SerializationError
, etc. - Extra diagnostics are provided, such as
PingDiagnostics
to track the jitter/RTT, orRollbackDiagnostics
to track the number of rollbacks
Fixed
- lightyear can now work properly when running on wasm even if the tab is put in the background! Thanks to https://github.com/Nul-led/bevy_web_keepalive/tree/main from @Nul-led
- Tons of bugfixes for replication edge cases
- Input handling has been refactored to be more robust and more independent from world replication. In particular inputs can be replicated every tick even if the world replication is less frequent
Breaking changes
- The serialization logic now uses
bincode
instead ofbitcode
- The
Controlled
component now has an extra fieldlifetime
that specified how to despawn the entity if the controlling client is disconnected Visibility
has been renamed toNetworkRelevance
to avoid a name conflict with bevy'sVisibility
- The
DisconnectEvent
now returns aDisconnectReason
explaining why the client was disconnected - The
PredictionConfig
,ReplicationConfig
,SharedConfig
now contain additional fields
What's Changed
- improve examples common by @cBournhonesque in #361
- fix examples by @cBournhonesque in #362
- despawn recursive predicted/interpolated entities by @cBournhonesque in #363
- send updates since we last sent an update, not since we last received an ACK for that entity by @cBournhonesque in #365
- add subscribe_ack to reliable sender, add subscribe_nack to all channels by @cBournhonesque in #366
- add common run conditions by @cBournhonesque in #368
- Update musli requirement from 0.0.121 to 0.0.122 by @dependabot in #367
- Add WebPlugin to keep running in background by @cBournhonesque in #371
- add simple_setup example by @cBournhonesque in #372
- fix action-state for other players by @cBournhonesque in #374
- Draw Confirmed entity outlines in xpbd_physics demo by @RJ in #375
- Rebroadcast remote players inputs to have more precise rollbacks when predicting other players by @cBournhonesque in #376
- add option to display confirmed entities by @cBournhonesque in #377
- collect rollback metrics, write to Diagnostics by @cBournhonesque in #378
- put rollback diagnostics into PredictionDiagnosticsPlugin by @cBournhonesque in #379
- Add PingDiagnosticPlugin by @cBournhonesque in #380
- Add delta compression by @cBournhonesque in #384
- add componentsync mode to Controlled by @cBournhonesque in #392
- fix replication issue with send_tick by @cBournhonesque in #399
- improve config docs by @cBournhonesque in #400
- Add user-provided hook to accept/reject connections by @cBournhonesque in #401
- switch to bevy_keepalive by @cBournhonesque in #403
- Add extra tests/docs for delta-compression by @cBournhonesque in #404
- Fix delta compression by @cBournhonesque in #406
- fix by @cBournhonesque in #409
- fix example by @cBournhonesque in #411
- make ClientConnection.client pub by @cBournhonesque in #412
- switch benchmark backend to criterion by @cBournhonesque in #413
- Support steam p2p sockets by @msvbg in #346
- fix remote inputs entity mapping by @cBournhonesque in #414
- Return DisconnectReason in the DisconnectEvent for clients by @cBournhonesque in #416
- remove None state and instead init NetworkingState without entering OnDisconnect by @cBournhonesque in #417
- update benchmarks: separate send/receive by @cBournhonesque in #420
- add trace feature with lots of trace instrumentation by @cBournhonesque in #422
- add channel bandwidth stats by @cBournhonesque in #424
- Rewrite packet builder by @cBournhonesque in #428
- Few QOL changes by @cBournhonesque in #429
- Replicate existing entities from client->server when client reconnects to a server by @cBournhonesque in #431
- add perf tracing logs by @cBournhonesque in #432
- add lz4 by @cBournhonesque in #433
- Remove anyhow, use thiserror by @cBournhonesque in #434
- Remove unused imports by @cBournhonesque in #438
- Fix docs by @cBournhonesque in #439
- cleanup unused deps by @cBournhonesque in #440
- Update criterion requirement from 0.3 to 0.5 by @dependabot in #442
- Update metrics requirement from 0.22 to 0.23 by @dependabot in #441
- Update tokio-tungstenite requirement from 0.21.0 to 0.23.0 by @dependabot in #445
- Remove unused imports leafwing by @cBournhonesque in #447
- Improve replication logic by @cBournhonesque in #446
- apply visual interpolation before transform propagate by @cBournhonesque in #451
- Removed bitcode by @cBournhonesque in #452
- Return an error message in case a message is too big to be fragmented by @cBournhonesque in #454
- Fix build packet when we cannot write the channel_id by @cBournhonesque in #458
- Re-use allocations during write by @cBournhonesque in #459
- flag to enable sending messages bigger than 300MB by @cBournhonesque in #460
- type-erased the replication systems by @cBournhonesque in #461
- add tools to profile with flamegraph by @cBournhonesque in #462
- enab...