Play Audio at the speed something is moving

Okay so I have a game mechanic that will open a door by moving the mouse. I’m using the dragRigidbody script that comes with Unity and a Hinge Joint. It works very well.

Now I really would like to know how to play audio depending on how the door is moving, if you move the door fast the audio should be loud and fast. If you move the door slowly, the audio should be quite and slow.

Hope I explained it well enough.

never tried it, but i think it should work by setting the dopplerlevel (the sound must a 3d sound afaik)

you could perhaps write a function to get the angle between the door and the wall, call this on each update when the door is being opened, compare the current angle to the angle at the last update and you can get the speed at which the door is opening, then combine that with a function to determine the volume of your audiosource.

for example

volume = speed / maxspeed;

you should be able to get an idea of the max speed you can open the door at by printing the speed with a debug and go in game and do some testing. The volume parameter has a range of 0.0-1.0.

this solution may be overly complex but its worth a shot