implement rotation key "r"

This commit is contained in:
yuni 2024-03-30 19:14:59 +01:00
parent 116cc4933c
commit 4b13530e4a
3 changed files with 16 additions and 3 deletions

View file

@ -24,6 +24,7 @@ Key features:
- t: toggle music (NOTE: currently no music is included in the git repo)
- m: mute sound effects
- q: enter/exit vehicle
- r: rotate (hold r while moving the mouse)
- f: toggle 3rd person view
- TAB: toggle augmented reality overlay (HUD, low-light amplifier)

View file

@ -224,9 +224,19 @@ fn apply_input_to_player(
if mouse_delta != Vec2::ZERO {
// Apply look update
let pitch = (mouse_delta.y * RADIANS_PER_DOT * settings.mouse_sensitivity).clamp(-PI / 2., PI / 2.);
let yaw = mouse_delta.x * RADIANS_PER_DOT * settings.mouse_sensitivity;
player_transform.rotation *= Quat::from_euler(EulerRot::ZYX, 0.0, -yaw, pitch).normalize();
let mouse_y_movement = (mouse_delta.y * RADIANS_PER_DOT * settings.mouse_sensitivity).clamp(-PI / 2., PI / 2.);
let mouse_x_movement = -mouse_delta.x * RADIANS_PER_DOT * settings.mouse_sensitivity;
let (pitch, yaw, rot);
if key_input.pressed(settings.key_rotate) {
pitch = 0.0;
yaw = 0.0;
rot = mouse_x_movement;
} else {
pitch = mouse_y_movement;
yaw = mouse_x_movement;
rot = 0.0;
}
player_transform.rotation *= Quat::from_euler(EulerRot::ZYX, rot, yaw, pitch).normalize();
}
if let Ok(sink) = thruster_sound_controller.get_single() {

View file

@ -27,6 +27,7 @@ pub struct Settings {
pub key_interact: KeyCode,
pub key_vehicle: KeyCode,
pub key_camera: KeyCode,
pub key_rotate: KeyCode,
pub key_reply1: KeyCode,
pub key_reply2: KeyCode,
pub key_reply3: KeyCode,
@ -76,6 +77,7 @@ impl Default for Settings {
key_interact: KeyCode::KeyE,
key_vehicle: KeyCode::KeyQ,
key_camera: KeyCode::KeyF,
key_rotate: KeyCode::KeyR,
key_reply1: KeyCode::Digit1,
key_reply2: KeyCode::Digit2,
key_reply3: KeyCode::Digit3,