Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Examples

This page lists the examples in the examples folder, roughly easiest first. Run the server with cargo run -- server and a client with cargo run -- client -c 1 (add --headless=false for a GUI).

Easy

  • simple_setup: minimal example, just the client and server plugins and a connection.
  • simple_box: the tutorial example. Client/server prediction and interpolation, plus an optional deterministic input-only P2P mode.
  • bevy_enhanced_inputs: integrating lightyear with the bevy_enhanced_input crate for input handling.

Medium

  • delta_compression: replicate a component by sending only the difference when it changes, instead of the full value.
  • network_visibility: only replicate a subset of entities to each player (interest management with rooms).
  • replication_groups: replicate entities that refer to other entities (a component containing an Entity), with entity mapping so the references stay valid on the client.
  • priority: bandwidth management. Cap the bytes per second on a link and let priorities decide which updates go first.

Advanced

  • avian_2d / avian_3d: replicate an Avian physics simulation (2D and 3D).
  • fps: prespawn bullets directly on the predicted timeline, with lag compensation for collisions between predicted and interpolated entities.
  • auth: how a client gets a ConnectToken from a backend to connect to a server.
  • lobby: change the network topology at runtime; any client can become the host instead of the dedicated server.
  • deterministic_replication: lockstep-style deterministic simulation.

There are also two bigger demos in demos: spaceships and projectiles.