bevy-networker-multiplayer
Little multiplayer plugin on top of networker-rs. Tired of big net libraries with big boilerplate? Here's the small solution!
How it works
The API stays small:
Replicated= entity should exist on the network#[sync]= component should sync over the wire#[sync(prefab(...))]= client-side visual prefab for that component#[sync(resource)]= sync a Bevy resource#[netmsg]= typed message / RPC-style traffic
NetResource is inserted automatically and is the bridge to networker-rs: start or join from it, then the plugin uses it to queue packets, flush them, and apply incoming replication back into Bevy.
Resources are synced as whole snapshots instead of using network ids. That makes them a good fit for match state, lobby state, money, chat history, and timers.
Example:
use *;
use ;
Basic server/client split:
use *;
use ;
const ADDRESS: &str = "127.0.0.1:5001";
;
That pattern is enough to get a server running, connect a client, and let the plugin handle replication, resource sync, and typed messages.
Basic moving-cubes demo without prediction:
The server starts a shared world of replicated cubes and moves them every frame. Each client opens its own window, receives the cube state, and renders the same motion locally. The cube visuals come from #[sync(prefab(...))], and the Position component automatically drives the spawned Transform on the client, so you do not need a separate visual sync system. New clients also receive a snapshot of the current state when they connect.
Client-side movement prediction lives in a separate example:
The prediction API is derived on tuple structs:
;
;
Example
Run the replication demo in two terminals:
The server spawns a replicated entity and moves it once per second. The client connects over UDP, receives spawn/update packets, and prints the replicated state it sees.
Run the message demo in two terminals:
The client sends chat and shoot messages. The server prints chat, broadcasts a reply, and turns shoot requests into replicated projectile entities.
Notes
- Uses UDP via
networker-rs - I found out lightyear existed just after making this
- Latest update: made sure entities don't snap back by dropping late packets