✨ bevy_stardust
Stardust is a batteries-included networking crate built for Bevy. Stardust intends to make networking easy, but lets you do the hard stuff when you want to.
World
and App
.Note: While you can use any transport layer, Stardust by itself only supports native UDP.
bevy_mod_scripting
supportThis applies to the UDP transport layer.
```rs // In a shared location
use bevy::prelude::; use bevy_stardust::shared::prelude::;
struct MyChannel;
rs
// On the client
use bevy::prelude::; use bevy_stardust::client::prelude::;
fn main() { let mut app = App::new(); app.addplugins(StardustClientPlugin); app.addplugins(ClientUdpTransportPlugin);
app.register_channel::<MyChannel>(ChannelConfig {
direction: ChannelDirection::Bidirectional,
}, ());
app.add_systems(WriteOctetStrings, sender_system);
}
fn sender_system(
connection: Res
writer.send("Hello, world!".into_bytes()).unwrap();
}
rs
// On the server
use bevy::prelude::; use bevy_stardust::server::prelude::;
fn main() { let mut app = App::new(); app.addplugins(StardustServerPlugin); app.addplugins(ServerUdpTransportPlugin { address: IpAddr::V4(Ipv4Addr::UNSPECIFIED), listenport: 12345, activeports: 12346..=12356, })
app.register_channel::<MyChannel>(ChannelConfig {
direction: ChannelDirection::Bidirectional,
}, ());
app.insert_resource(NetworkClientCap(64));
app.add_systems(ReadOctetStrings, receiver_system);
}
fn receiversystem(
reader: ChannelReader