- Home /
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.
Answer by reppiz01 · Jul 04, 2013 at 02:10 PM
never tried it, but i think it should work by setting the dopplerlevel (the sound must a 3d sound afaik)
Answer by SpecticalPro · Jul 04, 2013 at 03:30 PM
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
Your answer
Follow this Question
Related Questions
Audio is repeating. 3 Answers
On Mouse Click Play Sound 1 Answer
Playing Music Problem. 2 Answers
Changing Audio Pitch Dynamically 1 Answer
Random Audioclip. No Repeat ?? 1 Answer