From 5db669e428c20d4b24f7280da692acbd3d5fbc16 Mon Sep 17 00:00:00 2001 From: KingGurke Date: Sun, 1 Oct 2023 21:04:33 +0200 Subject: [PATCH 1/2] Added auto pitch-shift to engine sound --- src/game/player_controller.gd | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/game/player_controller.gd b/src/game/player_controller.gd index 430953a..9b3a210 100644 --- a/src/game/player_controller.gd +++ b/src/game/player_controller.gd @@ -70,10 +70,15 @@ func _process(delta): if !Input.is_action_pressed("brake"): momentum = Vector2(1,0).rotated(rotation) * momentum.length() - camera.position = Vector2((momentum.length() / max_speed) * camera_offset, 0) + camera.position = Vector2(get_speed_proportion() * camera_offset, 0) camera.rotation_degrees = momentum.angle() + 90 + $engine_sounds.pitch_scale = get_speed_proportion() * 1.2 + if momentum.length() > max_speed: momentum = momentum.normalized() * max_speed speed_changed.emit(momentum.length()) move_and_collide(momentum * delta) + +func get_speed_proportion(): + return (momentum.length() / max_speed) From 7805ce1c328c62890d13ef85f3e2937d4dd3adb0 Mon Sep 17 00:00:00 2001 From: KingGurke Date: Sun, 1 Oct 2023 21:06:56 +0200 Subject: [PATCH 2/2] fixed engine sound errors --- src/game/player_controller.gd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/game/player_controller.gd b/src/game/player_controller.gd index 9b3a210..73cfaa7 100644 --- a/src/game/player_controller.gd +++ b/src/game/player_controller.gd @@ -73,7 +73,7 @@ func _process(delta): camera.position = Vector2(get_speed_proportion() * camera_offset, 0) camera.rotation_degrees = momentum.angle() + 90 - $engine_sounds.pitch_scale = get_speed_proportion() * 1.2 + $engine_sounds.pitch_scale = get_speed_proportion() + .2 if momentum.length() > max_speed: momentum = momentum.normalized() * max_speed