Bevy GGRS
Bevy plugin for the GGRS P2P rollback networking library. Handles advancing game state and rollbacks via a dedicated schedule, snapshotting only the components and resources you register.
Quickstart
# Cargo.toml
[]
= { = "https://github.com/gschup/bevy_ggrs" }
use *;
use *;
type GgrsConfig = GgrsConfig; // replace u8 with your input type
new
.add_plugins
.insert_resource
// register components/resources for snapshotting
.
// provide inputs each frame
.add_systems
// your game logic — must be deterministic!
.add_systems
.insert_resource
.run;
// #[require(Rollback)] ensures Rollback is always added with Player —
// no need to include it manually in every spawn call.
;
For full P2P and spectator session examples, see examples/. For guides on writing correct rollback systems, see docs/pitfalls.md and docs/debugging-desyncs.md. For an overview of how bevy_ggrs works internally, see docs/architecture.md.
Live Demonstration (unmaintained)
bevy_ggrs has a demo app using matchbox for browser-based P2P. It is currently unmaintained and may not work with the latest version.
Compatible Versions
| bevy | bevy_ggrs | ggrs |
|---|---|---|
| 0.18 | main | main |
| 0.19 | 0.22 | 0.13.0 |
| 0.18 | 0.21 | 0.12.0 |
| 0.18 | 0.20 | 0.11.1 |
| 0.17 | 0.19 | 0.11.1 |
| 0.16 | 0.18 | 0.11.1 |
| 0.15 | 0.17 | 0.11.0 |
| 0.14 | 0.16 | 0.10.2 |
| 0.13 | 0.15 | 0.10.1 |
| 0.12 | 0.14 | 0.10 |
| 0.11 | 0.13 | 0.9.4 |
| 0.10 | 0.12 | 0.9.4 |
| 0.9 | 0.11 | 0.9.3 |
| 0.8 | 0.10 | 0.9 |
| 0.6 | 0.9 | 0.9 |
Community
- matchbox — WebRTC socket layer, pairs well with bevy_ggrs for browser/WASM P2P
- extreme_bevy — tutorial and example project: how to build a low-latency P2P web game with bevy_ggrs and matchbox
Thanks
to bevy_backroll and bevy_rollback for figuring out pieces of the puzzle that made bevy_ggrs possible. Special thanks to the helpful folks in the Bevy Discord for their support along the way.
Licensing
Bevy_GGRS is dual-licensed under either
- MIT License: Also available online
- Apache License, Version 2.0: Also available online
at your option.
