diff --git a/src/components/PlayerController.jsx b/src/components/PlayerController.jsx index 37d031a..8f0670f 100644 --- a/src/components/PlayerController.jsx +++ b/src/components/PlayerController.jsx @@ -107,8 +107,8 @@ export const PlayerController = ({ if (player.id !== id) return; const time = clock.getElapsedTime(); if (!body.current && !mario.current) return; - engineSound.current.setVolume(currentSpeed / 300 + 0.2); - engineSound.current.setPlaybackRate(currentSpeed / 10 + 0.1); + engineSound.current.setVolume(Math.abs(currentSpeed) / 300 + 0.2); + engineSound.current.setPlaybackRate(Math.abs(currentSpeed) / 10 + 0.1); jumpSound.current.setPlaybackRate(1.5); jumpSound.current.setVolume(0.5); driftSound.current.setVolume(0.2); diff --git a/src/components/PlayerControllerGamepad.jsx b/src/components/PlayerControllerGamepad.jsx index 3b1a0b5..1d95c3a 100644 --- a/src/components/PlayerControllerGamepad.jsx +++ b/src/components/PlayerControllerGamepad.jsx @@ -104,8 +104,8 @@ export const PlayerControllerGamepad = ({ const time = clock.getElapsedTime(); if (!body.current && !mario.current) return; isDrifting.current = driftLeft.current || driftRight.current; - engineSound.current.setVolume(currentSpeed / 300 + 0.2); - engineSound.current.setPlaybackRate(currentSpeed / 10 + 0.1); + engineSound.current.setVolume(Math.abs(currentSpeed) / 300 + 0.2); + engineSound.current.setPlaybackRate(Math.abs(currentSpeed) / 10 + 0.1); jumpSound.current.setPlaybackRate(1.5); jumpSound.current.setVolume(0.5); driftSound.current.setVolume(0.2); diff --git a/src/components/PlayerControllerKeyboard.jsx b/src/components/PlayerControllerKeyboard.jsx index 4580de0..a424140 100644 --- a/src/components/PlayerControllerKeyboard.jsx +++ b/src/components/PlayerControllerKeyboard.jsx @@ -110,8 +110,8 @@ export const PlayerControllerKeyboard = ({ if (player.id !== id) return; const time = clock.getElapsedTime(); if (!body.current && !mario.current) return; - engineSound.current.setVolume(currentSpeed / 300 + 0.2); - engineSound.current.setPlaybackRate(currentSpeed / 10 + 0.1); + engineSound.current.setVolume(Math.abs(currentSpeed) / 300 + 0.2); + engineSound.current.setPlaybackRate(Math.abs(currentSpeed) / 10 + 0.1); jumpSound.current.setPlaybackRate(1.5); jumpSound.current.setVolume(0.5); driftSound.current.setVolume(0.2); diff --git a/src/components/PlayerControllerTouch.jsx b/src/components/PlayerControllerTouch.jsx index 982d106..cdd06f7 100644 --- a/src/components/PlayerControllerTouch.jsx +++ b/src/components/PlayerControllerTouch.jsx @@ -100,8 +100,8 @@ export const PlayerControllerTouch = ({ if (player.id !== id) return; const time = clock.getElapsedTime(); if (!body.current && !mario.current) return; - engineSound.current.setVolume(currentSpeed / 300 + 0.2); - engineSound.current.setPlaybackRate(currentSpeed / 10 + 0.1); + engineSound.current.setVolume(Math.abs(currentSpeed) / 300 + 0.2); + engineSound.current.setPlaybackRate(Math.abs(currentSpeed) / 10 + 0.1); jumpSound.current.setPlaybackRate(1.5); jumpSound.current.setVolume(0.5); driftSound.current.setVolume(0.2);