implement rotation stabilizer (key Y)

This commit is contained in:
yuni 2024-04-11 21:06:21 +02:00
parent 9ea79ff80f
commit d0df5c5dbd
3 changed files with 15 additions and 1 deletions

View file

@ -41,6 +41,7 @@ Links:
- Tab: Toggle HUD/AR
- F11: Toggle fullscreen
- F: Toggle 3rd person view
- Y: Toggle rotation stabilizer
- T: Toggle music
- M: Toggle sound effects
- Cheats

View file

@ -117,10 +117,15 @@ pub fn update_fov(
pub fn handle_input(
keyboard_input: Res<ButtonInput<KeyCode>>,
mut settings: ResMut<settings::Settings>,
mut ew_sfx: EventWriter<audio::PlaySfxEvent>,
) {
if keyboard_input.just_pressed(settings.key_camera) {
settings.third_person ^= true;
}
if keyboard_input.just_pressed(settings.key_rotation_stabilizer) {
ew_sfx.send(audio::PlaySfxEvent(audio::Sfx::Click));
settings.rotation_stabilizer_active ^= true;
}
}
fn manage_player_actor(
@ -301,7 +306,11 @@ pub fn apply_input_to_player(
}
}
let angular_slowdown: f64 = (2.0 - engine.reaction_wheels.powf(0.01).clamp(1.001, 1.1)) as f64;
let angular_slowdown: f64 = if settings.rotation_stabilizer_active {
(2.0 - engine.reaction_wheels.powf(0.01).clamp(1.001, 1.1)) as f64
} else {
1.0
};
if pitch_yaw_rot.length_squared() > 1.0e-18 {
play_reactionwheel_sound = true;
pitch_yaw_rot *= settings.mouse_sensitivity * sensitivity_factor * engine.reaction_wheels;

View file

@ -19,6 +19,7 @@ pub struct Settings {
pub hud_active: bool,
pub is_zooming: bool,
pub third_person: bool,
pub rotation_stabilizer_active: bool,
pub key_selectobject: MouseButton,
pub key_zoom: MouseButton,
pub key_togglehud: KeyCode,
@ -37,6 +38,7 @@ pub struct Settings {
pub key_vehicle: KeyCode,
pub key_camera: KeyCode,
pub key_rotate: KeyCode,
pub key_rotation_stabilizer: KeyCode,
pub key_mouseup: KeyCode,
pub key_mousedown: KeyCode,
pub key_mouseleft: KeyCode,
@ -101,6 +103,7 @@ impl Default for Settings {
hud_active: false,
is_zooming: false,
third_person: false,
rotation_stabilizer_active: true,
key_selectobject: MouseButton::Left,
key_zoom: MouseButton::Right,
key_togglehud: KeyCode::Tab,
@ -119,6 +122,7 @@ impl Default for Settings {
key_vehicle: KeyCode::KeyQ,
key_camera: KeyCode::KeyF,
key_rotate: KeyCode::KeyR,
key_rotation_stabilizer: KeyCode::KeyY,
key_mouseup: KeyCode::KeyI,
key_mousedown: KeyCode::KeyK,
key_mouseleft: KeyCode::KeyJ,