diff --git a/client/src/input/mod.rs b/client/src/input/mod.rs index 4034ea3..9cf1f65 100644 --- a/client/src/input/mod.rs +++ b/client/src/input/mod.rs @@ -12,4 +12,16 @@ pub fn plugin(app: &mut App) { cursor_grab::plugin, head_orientation::plugin, )); + + // Make entities require the `Pickable` component if + // they should be considered for the picking system. + app.insert_resource(MeshPickingSettings { + require_markers: true, + ..default() + }); + + // Insert `MeshPickingCamera` component on any 3D camera. + app.add_observer(|event: On, mut commands: Commands| { + commands.entity(event.entity).insert(MeshPickingCamera); + }); } diff --git a/client/src/main.rs b/client/src/main.rs index 5023c49..5aeb8ea 100644 --- a/client/src/main.rs +++ b/client/src/main.rs @@ -51,16 +51,6 @@ fn main() -> Result { bevy_fix_cursor_unlock_web::FixPointerUnlockPlugin, )); - // Make entities require the `Pickable` component if - // they should be considered for the picking system. - app.insert_resource(UiPickingSettings { - require_markers: true, - }); - app.insert_resource(MeshPickingSettings { - require_markers: true, - ..default() - }); - app.add_plugins(( common::assets::plugin, common::network::plugin, @@ -131,6 +121,5 @@ fn handle_predicted_player_spawn(event: On, mut commands: Comman InputMarker::::default(), // TODO: Attach camera to player head eventually. Camera3d::default(), - MeshPickingCamera, )); } diff --git a/client/src/ui/mod.rs b/client/src/ui/mod.rs index b852000..f8dfc62 100644 --- a/client/src/ui/mod.rs +++ b/client/src/ui/mod.rs @@ -5,4 +5,10 @@ mod loading_screen; pub fn plugin(app: &mut App) { app.add_plugins((crosshair::plugin, loading_screen::plugin)); + + // Make entities require the `Pickable` component if + // they should be considered for the picking system. + app.insert_resource(UiPickingSettings { + require_markers: true, + }); }