https://github.com/johanhelsing/bevy_roll_safe
Rollback-safe implementations and utilities for Bevy Engine
https://github.com/johanhelsing/bevy_roll_safe
bevy deterministic game-development rollback
Last synced: 10 months ago
JSON representation
Rollback-safe implementations and utilities for Bevy Engine
- Host: GitHub
- URL: https://github.com/johanhelsing/bevy_roll_safe
- Owner: johanhelsing
- License: apache-2.0
- Created: 2023-09-11T06:21:24.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-12-19T21:06:34.000Z (about 1 year ago)
- Last Synced: 2025-03-28T16:37:58.832Z (11 months ago)
- Topics: bevy, deterministic, game-development, rollback
- Language: Rust
- Homepage:
- Size: 43 KB
- Stars: 14
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE-APACHE
Awesome Lists containing this project
README
# bevy_roll_safe
[](https://crates.io/crates/bevy_roll_safe)

[](https://docs.rs/bevy_roll_safe)
Rollback-safe implementations and utilities for Bevy Engine.
## Motivation
Some of Bevy's features can't be used in a rollback context (with crates such as [`bevy_ggrs`]). This is either because they behave non-deterministically, rely on inaccessible local system state, or are tightly coupled to the `Main` schedule.
## Roadmap
- [x] States
- [x] Basic freely mutable states
- [x] `OnEnter`/`OnLeave`/`OnTransition`
- [ ] Sub-States
- [ ] Computed states
- [ ] Roll-safe events
- [x] FrameCount
- [ ] Events
## States
Bevy states when added through `app.add_state::()` have two big problems:
1. They happen in the `StateTransition` schedule within the `MainSchedule`
2. If rolled back to the first frame, `OnEnter(InitialState)` is not re-run.
This crate provides an extension method, `add_roll_state::(schedule)`, which lets you add a state to the schedule you want, and a resource, `InitialStateEntered` which can be rolled back and tracks whether the initial `OnEnter` should be run (or re-run on rollbacks to the initial frame).
See the [`states`](https://github.com/johanhelsing/bevy_roll_safe/blob/main/examples/states.rs) example for usage with [`bevy_ggrs`].
## Cargo features
- `bevy_ggrs`: Enable integration with [`bevy_ggrs`]
- `math_determinism`: Enable cross-platform determinism for operations on Bevy's (`glam`) math types.
## Bevy Version Support
|bevy|bevy_roll_safe|
|----|--------------|
|0.15|0.4, main |
|0.14|0.3 |
|0.13|0.2 |
|0.12|0.1 |
## License
`bevy_roll_safe` is dual-licensed under either
- MIT License (./LICENSE-MIT or )
- Apache License, Version 2.0 (./LICENSE-APACHE or )
at your option.
## Contributions
PRs welcome!
[`bevy_ggrs`]: https://github.com/gschup/bevy_ggrs