better reaction wheel sound

This commit is contained in:
yuni 2024-03-31 05:13:13 +02:00
parent 61e02ed6ca
commit 852dd79657

View file

@ -256,8 +256,7 @@ fn apply_input_to_player(
angularvelocity.0 *= angular_slowdown.clamp(0.97, 1.0);
}
else {
if angularvelocity.length_squared() > 0.0000001 {
play_reactionwheel_sound = true;
if angularvelocity.length_squared() > 0.001 {
angularvelocity.0 *= angular_slowdown;
}
else {
@ -268,20 +267,18 @@ fn apply_input_to_player(
// Play sound effects
if let Ok(sink) = electricmotor_sound_controller.get_single() {
let volume = sink.volume();
let max = (pitch_yaw_rot.length() * 10.0).clamp(0.2, 1.0);
let max_speed = 1.0;
let rise = 0.07;
let fall = 0.15;
let speed = sink.speed();
let action = pitch_yaw_rot.length_squared().powf(0.2) * 0.0005;
if play_reactionwheel_sound {
sink.set_volume((volume + rise).clamp(0.0, max));
sink.set_speed((volume + rise).clamp(0.2, max * max_speed));
sink.set_volume((volume + action).clamp(0.0, 1.0));
sink.set_speed((speed + action * 0.2).clamp(0.2, 0.5));
sink.play()
} else {
if volume <= 0.01 {
sink.pause()
} else {
sink.set_volume((volume - fall).clamp(0.0, max));
sink.set_speed((volume - fall).clamp(0.2, max * max_speed));
sink.set_volume((volume - 0.01).clamp(0.0, 1.0));
sink.set_speed((speed - 0.03).clamp(0.2, 0.5));
}
}
}