Screenshots use previous camera position
- Dominant language
- Rust
- Stars
- 48.2k
- Forks
- 4.8k
- Avg merge
- 3d 22h
- Merged PRs (30d)
- 161
Description
## Bevy version
0.15.0
## What you did
In `PostUpdate`, when user triggers a screenshot:
```rust
let (mut proj, mut transform) = icon_camera.single_mut(); // icon_camera is Query<(&mut OrthographicProjection, &mut Transform), (With, Without, Without)>
let (center, size) = get_camera_parameters(aabb);
transform.translation = Vec3::new(center.x, center.y, 0.);
let size_max = size.x.max(size.y);
proj.scaling_mode = ScalingMode::Fixed{width: size_max, height: size_max};
//proj.scale = size_max / 512.0;
proj.area = Rect::from_center_size(bevy::math::Vec2::new(center.x, center.y), bevy::math::Vec2::new(size_max, size_max));
println!("pos {}, size {}", center, size_max);
commands
.spawn(Screenshot::image(image.clone()))
.observe(bevy::render::view::screenshot::save_to_disk(path));
```
I'm setting a camera position and taking a screenshot when the user saves an object in my game
## What went wrong
When I trigger the screenshot once and look at the saved image, it isn't at the right position, but instead the initial position of the icon camera (from when I created it in `PreStartup`.
Then, when I trigger it a second time, it's now at the right position, as long as the object didn't move. Each screenshot uses the previous camera position, instead of what I just changed it to
I think this is a bug, but it could also be intended behaviour? Does Bevy want me to wait a frame for the image to update?
Contributor guide
Assessment
This issue has not been assessed yet.