add settings.mouse_sensitivity

This commit is contained in:
yuni 2024-03-30 16:27:56 +01:00
parent b945d7bda7
commit 0456b8506c
2 changed files with 4 additions and 4 deletions

View file

@ -28,7 +28,6 @@ pub const RADIANS_PER_DOT: f32 = 1.0 / 180.0;
pub struct CameraController {
pub enabled: bool,
pub initialized: bool,
pub sensitivity: f32,
pub pitch: f32,
pub yaw: f32,
}
@ -38,7 +37,6 @@ impl Default for CameraController {
Self {
enabled: true,
initialized: false,
sensitivity: 0.5,
pitch: 1.0, // pitch=0/yaw=0 -> face sun
yaw: 0.3,
}
@ -245,9 +243,9 @@ fn run_camera_controller(
if mouse_delta != Vec2::ZERO {
// Apply look update
controller.pitch = (controller.pitch
+ mouse_delta.y * RADIANS_PER_DOT * controller.sensitivity)
+ mouse_delta.y * RADIANS_PER_DOT * settings.mouse_sensitivity)
.clamp(-PI / 2., PI / 2.);
controller.yaw += mouse_delta.x * RADIANS_PER_DOT * controller.sensitivity;
controller.yaw += mouse_delta.x * RADIANS_PER_DOT * settings.mouse_sensitivity;
player_transform.rotation = Quat::from_euler(EulerRot::ZYX, 0.0, -controller.yaw, controller.pitch).normalize();
}

View file

@ -7,6 +7,7 @@ pub struct Settings {
pub mute_music: bool,
pub volume_sfx: u8,
pub volume_music: u8,
pub mouse_sensitivity: f32,
pub font_size_hud: f32,
pub font_size_conversations: f32,
pub hud_active: bool,
@ -55,6 +56,7 @@ impl Default for Settings {
mute_music: default_mute_music,
volume_sfx: 100,
volume_music: 100,
mouse_sensitivity: 0.5,
font_size_hud: 32.0,
font_size_conversations: 32.0,
hud_active: false,