6 releases

Uses new Rust 2021

0.10.0 Aug 17, 2022
0.9.0 Feb 13, 2022
0.1.3 Jan 17, 2022

#296 in Game dev

Download history 90/week @ 2022-08-13 245/week @ 2022-08-20 113/week @ 2022-08-27 41/week @ 2022-09-03 37/week @ 2022-09-10 31/week @ 2022-09-17 38/week @ 2022-09-24 57/week @ 2022-10-01 18/week @ 2022-10-08 16/week @ 2022-10-15 106/week @ 2022-10-22 104/week @ 2022-10-29 91/week @ 2022-11-05 47/week @ 2022-11-12 56/week @ 2022-11-19 119/week @ 2022-11-26

333 downloads per month

MIT/Apache

175KB
539 lines

GGRS LOGO

crates.io GitHub Workflow Status

Bevy GGRS

Bevy plugin for the GGRS P2P rollback networking library. The plugin creates a custom stage with a separate schedule, which handles correctly advancing the gamestate, including rollbacks. It efficiently handles saving and loading of the gamestate by only snapshotting relevant parts of the world, as defined by the user. It is supposed to work with the latest released version of bevy.

For explanation on how to use it, check the 👉examples!

Live Demonstration

bevy_GGRS has a demo app you can try in the browser! It uses matchbox to facilitate communication between browsers. Try it out with a friend! Just click the link and match with another player! (You can also open the link in two separate windows to play against yourself)

How it works

The GGRS plugin creates a custom GGRSStage which owns a separate schedule. Inside this schedule, the user can add stages and systems as they wish. When the default schedule runs the GGRSStage, it polls the session and executes resulting GGRSRequests, such as loading, saving and advancing the gamestate.

  • advancing the gamestate is done by running the internal schedule once.
  • saving the gamestate is done by creating a snapshot of entities tagged with a bevy_ggrs::Rollback component and saving only the components that were registered through register_rollback_type::<YourCoolComponent>(). The plugin internally keeps track of the snapshots together with the GGRS session.
  • loading the gamestate applies the snapshot by overwriting, creating and deleting entities tagged with a bevy_ggrs::Rollback component and updating the registered components values.

Since bevy_ggrs operates with a separate schedule, compatibility with other plugins might be complicated to achieve out of the box, as all gamestate-relevant systems needs to somehow end up inside the internal GGRS schedule to be updated together the rest of the game systems.

Compatible Versions

bevy bevy_ggrs ggrs
0.8 main main
0.8 0.10 0.9
0.6 0.9 0.9

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, providing useful help and pointers all over the place.

Licensing

Bevy_GGRS is dual-licensed under either

at your option.

Dependencies

~22–32MB
~644K SLoC