Crates.io | lightyear_avian |
lib.rs | lightyear_avian |
version | 0.21.0-rc.2 |
created_at | 2025-01-28 01:40:08.479807+00 |
updated_at | 2025-07-01 04:27:03.770047+00 |
description | Helper library to use Lightyear with Avian |
homepage | |
repository | https://github.com/cBournhonesque/lightyear |
max_upload_size | |
id | 1533152 |
size | 128,699 |
A library for writing server-authoritative multiplayer games with Bevy. Compatible with wasm via WebTransport.
https://github.com/cBournhonesque/lightyear/assets/8112632/7b57d48a-d8b0-4cdd-a16f-f991a394c852
Demo using one server with 2 clients. The entity is predicted (slightly ahead of server) on the controlling client and interpolated (slightly behind server) on the other client. The server only sends updates to clients 10 times per second but the clients still see smooth updates.
You can first check out the examples.
To quickly get started, you can follow this tutorial, which re-creates the simple_box example.
You can also find more information in this WIP book.
Lightyear provides a simple API for sending and receiving messages, and for replicating entities and components:
Messages
, Components
, Inputs
that can be sent over
the network; as well as the Channels
to be used:// messages
app.add_message::<Message1>();
// inputs
app.add_plugins(InputPlugin::<Inputs>::default());
// components
app.register_component::<PlayerId>()
.add_prediction(PredictionMode::Once)
.add_interpolation(InterpolationMode::Once);
// channels
app.add_channel::<Channel1>(ChannelSettings {
mode: ChannelMode::OrderedReliable(ReliableSettings::default()),
..default()
});
to enable replication, the user just needs to add a Replicate
component to entities that need to be replicated.
all network-related behaviour is defined via bevy components: MessageReceiver<Message1>
, ReplicationSender
, etc.
bincode
as a default serializer, but you can provide your own serialization functionClient
, and lightyear makes sure that the client input for tick N
will
be processed on tick N
on the server.
Inputs are protected against packet-loss: each packet will contain the client inputs for the last few frames.leafwing
feature, there is a special integration with
the leafwing-input-manager
crate, where
your leafwing
inputs are networked for you!Replicate
bundle will be automatically replicated to clients.Rooms
ClientConfig
and ServerConfig
structs.tracing
and metrics
libraries to emit spans and logs around most events (
sending/receiving messages, etc.). The metrics can be exported to Prometheus for analysis.Lightyear has plenty of examples demonstrating all these features, as well as the integration with other bevy
crates such as avian
Lightyear | Bevy |
---|---|
0.20 | 0.16 |
0.18-0.19 | 0.15 |
0.16-0.17 | 0.14 |
0.10-0.15 | 0.13 |
0.1-0.9 | 0.12 |