use bevy::prelude::*; use bevy::render::camera::Camera; pub fn startup(mut commands: Commands) { let mut bundle = (Camera2dBundle::default(), IsDefaultUiCamera); bundle.0.projection.scale = 0.5; commands.spawn(bundle); } #[derive(Component, Debug)] pub struct Watched; pub fn update( watched: Query<&Transform, With>, mut camera: Query<&mut Transform, (With, Without)>, ) { if let Ok(mut camera) = camera.get_single_mut() { if let Ok(watched) = watched.get_single() { camera.translation.x = watched.translation.x } else { camera.translation = Vec3::ZERO; } } }