//! A minimal example of how to add picking support to your bevy app. use bevy::prelude::*; use bevy_mod_picking::prelude::*; fn main() { App::new() .add_plugins(DefaultPlugins.set(low_latency_window_plugin())) // All you need to do is add the picking plugin, with your backend of choice enabled in the // cargo features. By default, the bevy_mod_raycast backend is enabled via the // `backend_raycast` feature. .add_plugins(DefaultPickingPlugins) .insert_resource(DebugPickingMode::Normal) .add_systems(Startup, setup) .run(); } fn setup( mut commands: Commands, mut meshes: ResMut>, mut materials: ResMut>, ) { commands.spawn(( PbrBundle { mesh: meshes.add(bevy_render::mesh::PlaneMeshBuilder::from_size(Vec2::splat( 5.0, ))), material: materials.add(Color::srgb(0.3, 0.5, 0.3)), ..default() }, PickableBundle::default(), // Optional: adds selection, highlighting, and helper components. )); commands.spawn(( PbrBundle { mesh: meshes.add(Cuboid::default()), material: materials.add(Color::srgb(0.8, 0.7, 0.6)), transform: Transform::from_xyz(0.0, 0.5, 0.0), ..default() }, PickableBundle::default(), // Optional: adds selection, highlighting, and helper components. )); commands.spawn(PointLightBundle { point_light: PointLight { shadows_enabled: true, ..default() }, transform: Transform::from_xyz(4.0, 8.0, -4.0), ..default() }); commands.spawn((Camera3dBundle { transform: Transform::from_xyz(3.0, 3.0, 3.0).looking_at(Vec3::ZERO, Vec3::Y), ..default() },)); }