use super::Player; use bevy::prelude::*; #[derive(Component, Reflect, Default, Debug)] #[reflect(Component)] pub struct Pickable; // very simple, crude picking (as in picking up objects) implementation pub fn picking( players: Query<&GlobalTransform, With>, pickables: Query<(Entity, &GlobalTransform), With>, mut commands: Commands, ) { for player_transforms in players.iter() { for (pickable, pickable_transforms) in pickables.iter() { let distance = player_transforms .translation() .distance(pickable_transforms.translation()); if distance < 2.5 { commands.entity(pickable).despawn_recursive(); } } } } pub struct PickingPlugin; impl Plugin for PickingPlugin { fn build(&self, app: &mut App) { app.register_type::().add_systems( Update, ( picking, //.run_if(in_state(AppState::Running)), ), ); } }