fix bug
This commit is contained in:
@@ -6,7 +6,7 @@ use crate::{
|
||||
};
|
||||
use bevy::{
|
||||
input::mouse::AccumulatedMouseMotion, pbr::NotShadowCaster, prelude::*,
|
||||
render::view::RenderLayers,
|
||||
render::view::RenderLayers, window::PrimaryWindow,
|
||||
};
|
||||
|
||||
#[derive(Debug, Component)]
|
||||
@@ -24,7 +24,7 @@ impl Default for CameraSensitivity {
|
||||
struct WorldModelCamera;
|
||||
|
||||
pub fn plugin(app: &mut App) {
|
||||
app.add_systems(OnEnter(GameState::Playing), init_player)
|
||||
app.add_systems(OnEnter(GameState::Playing), (init_player, hide_cursor))
|
||||
.add_systems(Update, move_camera.run_if(in_state(GameState::Playing)))
|
||||
.add_systems(
|
||||
RunFixedMainLoop,
|
||||
@@ -97,9 +97,14 @@ pub fn init_player(
|
||||
));
|
||||
});
|
||||
}
|
||||
fn hide_cursor(mut windows: Query<&mut Window, With<PrimaryWindow>>) {
|
||||
// Query returns one window typically.
|
||||
for mut window in windows.iter_mut() {
|
||||
window.cursor_options.visible = false;
|
||||
}
|
||||
}
|
||||
|
||||
use std::f32::consts::FRAC_PI_2;
|
||||
const PITCH_LIMIT: f32 = FRAC_PI_2 - 0.01;
|
||||
const PITCH_LIMIT: f32 = std::f32::consts::FRAC_PI_2 - 0.01;
|
||||
|
||||
pub fn move_camera(
|
||||
accumulated_mouse_motion: Res<AccumulatedMouseMotion>,
|
||||
|
||||
Reference in New Issue
Block a user