Expand description
Bevy, where was I?
A tiny Bevy library that saves the camera position when the program closes, and restores it when you launch the application again. This is useful when debugging and you don’t want to continuously change your hardcoded camera coordinates.
Note that this actually works for any Transform component, and not only restores translation
information, but also scale and rotation.
This crate is compatible with bevy_panorbit_camera and with Bevy’s built-in camera controllers.
§Usage
Add the plugin:
.add_plugins(WhereWasIPlugin::default())§For a camera
To save the translation and rotation of a camera, add the WhereWasI component to an entity with a
Camera component:
commands.spawn((
Camera::default(),
WhereWasI::camera(),
));Note: WhereWasI::camera() is equivalent to WhereWasI::from_name("camera").
§For other entities
For other entities, a name has to be provided.
Add the WhereWasI component to an entity with a Transform:
commands.spawn((
PointLight::default(),
WhereWasI::from_name("point_light"),
));Since WhereWasI indicates that Transform is a required component, we can omit it and
WhereWasI will construct it. If you want to change the initial state of the Transform before a
savefile exists, add a Transform component to the bundle:
commands.spawn((
PointLight::default(),
Transform::from_xyz(5.0, 2.0, 5.0),
WhereWasI::from_name("point_light"),
));See the 3D scene example for a complete example.
§Save files
The save files will by default be stored in ./assets/saves. You likely want to add this directory
to you .gitignore. Alternatvely, you can configure a different directory when initializing
the plugin. For example, you can store the savefiles in the user’s .config directory:
.add_plugins(WhereWasIPlugin {
directory: "~/.config/bevy-saves/my-game".into(),
})WhereWasIPlugin will make sure the directory exists if it doesn’t already.
§Bevy version compatibility
| bevy | bevy-where-was-i |
|---|---|
| 0.18 | 0.4.* |
| 0.17 | 0.3.* |
| 0.16 | 0.2.* |
| 0.15 | 0.1.* |
§License
Structs§
- Where
WasI - A component that saves a
Transformto disk and restores it when you reopn the application. - Where
WasI Plugin - Plugin that saves the
Transformstate after closing a Bevy application, and restores it when launching the application again.