- Home /
Question by
Daniel 13 · Nov 01, 2010 at 06:40 AM ·
audiogetkeyplayoneshotdistort
Audio trigger by key press - problems
Hello I want to play sounds on certain key presses so far what I have makes an awfully distorted sound - tried aiff, wav, ogg. What am I doing wrong/missing?
var audio01 : AudioClip; function Update () { if (Input.GetKey ("1")) { audio.PlayOneShot(audio01);
} }
thanks in advance Daniel
Comment
Best Answer
Answer by · Nov 01, 2010 at 06:55 AM
Try changing it to:
if (Input.GetKeyDown ("1"))
Otherwise, it will start playing the audio every frame that you have the key pressed.
Your answer
![](https://koobas.hobune.stream/wayback/20220613081526im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Distorted audio clips. Help please. 2 Answers
AUDIO ISSUES - PlayOneShot... is cutting short... I think? 2 Answers
My soundclip is noisy? 2 Answers
AudioSource.PlayOneShot only works ONCE on Unity 5? 1 Answer